JCD JCD - 1 year ago 163
PHP Question

base64_encode in phpmailer

I am trying to add the following hyperlink to an email. This link will direct a user to access a dynamic sales order. It works when its listed on a webpage but not within an email.

This works when listed on my page:

$str = '[INVOICENO] =' . $OrderNumber . '';

echo ' <a href="http://n-server/nameofsoftware/PlatformRO/WebClient/NTLM/1/Integration?p=RLV&fc=de9766b2-4d43-4b93-b55d-0afac57bf79b&q=' . base64_encode ( $str ) . '">$OrderNumber</a> ';

Now i'm trying to send the same link within an email

$str = '[INVOICENO] =' . $OrderNumber . '';

$email_message = '
<a href="http://n-server/nameofsoftware/PlatformRO/WebClient/NTLM/1/Integration?p=RLV&fc=de9766b2-4d43-4b93-b55d-0afac57bf79b&q=' . base64_encode ( $str ) . '">$OrderNumber</a>


Is there an issue with using base64_encode within an email?

I tried to turn it into a variable and that still didnt work either.

Any ideas?


The problem is the link is broken within an email.

This is an example of the link when its echo'd on a webpage:


This is an example of the link when its within an email:

http://n-server/nameofsoftware/PlatformRO/WebClient/Client/Result?fc=de9766b2-4d43-4b93-b55d-0afac57bf79b&q= 3846411&displayOneDoc=False&orgId=1

Answer Source

use urlencode php

This function is convenient when encoding a string to be used in a query part of a URL, as a convenient way to pass variables to the next page



 <strong>View Order:</strong>

<a href='nserver2/nameofsoftware/PlatformRO/WebClient/NTLM/1/<?php echo urlencode(trim(base64_encode ("INVOICENO=". $OrderNumber))); ?>'> <?php echo $OrderNumber ?></a>




    $OrderNumber='123';  //ASSUMPTION

    $str = '[INVOICENO] ='.$OrderNumber;

    $final_string = urlencode(trim(base64_encode ($str))); 

    $email_message = '
    <a href="http://n-server/nameofsoftware/PlatformRO/WebClient/NTLM/1/Integration?p=RLV&fc=de9766b2-4d43-4b93-b55d-0afac57bf79b&q='.$final_string.' "> '.$OrderNumber.'</a>';


    <li> <strong>View Order:</strong>
    <?php echo $email_message; ?>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download