php - html email issue for a tag value
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 = '[email protected]';
// 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 <[email protected]>' . "\r\n";
$headers .= 'From: test user <[email protected]>' . "\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.
Answer
Solution:
Try running
on the incoming parameters. Example:
Answer
Solution:
I think you should encode the URL on the email. Plus, you probable have magic_quotes_gpc "on" that is not recommended.
I always use PHPMailer, it saves a lot of work and helps on these problems
Answer
Solution:
try this:
Answer
Solution:
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