【发布时间】:2011-11-28 08:37:36
【问题描述】:
我正在通过 php 邮件功能向客户端发送 html 电子邮件。而 & 符号以粗体显示在电子邮件替换中产生问题! %20 类似于我的 id 中的字符,如下所示(粗体)。
http://test.com/test-page.php?id=abcd**!**1234&cat_id=23
下面是我的代码。 $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);
发送邮件后,我收到了!和 %20 喜欢电子邮件中的字符。 我也在电子邮件中尝试了 & except & 但仍然没有用!在我的电子邮件 html 中添加。
【问题讨论】:
标签: php email html-email