I am sending html email to the client via php mail function. while & sign shown in bold creating problems in email replacing ! %20 something like characters within my ids such as below(in bold).
http://test.com/test-page.php?id=abcd**!**1234&cat_id=23
Below is my code.
$to = ‘test@abc.com’;
// subject
$subject = 'test';
//message
$message.='<html><head><meta charset="UTF-8" /></head><body><p><a href="http://test.com/test-page.php?id=abcd1234&cat_id=23" target="_blank">Wine **&** Dine Offers</a></p></body></html>';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
// Additional headers
$headers .= 'To: test <test@abc.com>' . "\r\n";
$headers .= 'From: test user <no-reply@test.com>' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
After sending mail i am getting ! and %20 like characters in email.
I also tried & except & in email but no use still ! adding within my email html.
I changed the encoding settings on phpmailer to use base64 encoding using
$mail->Encoding=”base64”
This solved my problem.
As there is issue for HTML mail meassage exceeds length 998 or something i got the above solution to it. 🙂
http://www.jeremytunnell.com/posts/really-hairy-problem-with-seemingly-random-crlf-and-spaces-inserted-in-emails