php邮件中的&符号" FROM"头

时间:2017-07-10 18:27:53

标签: php forms email escaping

好的,我很难过。我的客户在公司名称中有一个&符号。比如"比尔& Bob Associates"。所以,我有一个像以下一样的行:

 $headers  = "From: Bill & Bob Associates, LLC <info@billbob.com>\r\n";

&amp;正在破坏电子邮件中的内容;

From: info@host.webhost.com,
&@host.webhost.com, Associates@host.webhost.com,
LLC <info@billbob.com>

尝试了%26但是没有用。

任何帮助都将不胜感激。

2 个答案:

答案 0 :(得分:0)

可能像:

$headers = "From: ". mb_encode_mimeheader('Bill & Bob Associates, LLC', 'UTF-8', 'Q') ." <info@billbob.com>\r\n";

或者您可以尝试:

$headers = "From: =?UTF-8?B?". base64_encode('Bill & Bob Associates, LLC') ."?= <info@billbob.com>\r\n"

答案 1 :(得分:0)

@nanocv在正确的轨道上,但是,该字符串已经是双引号。但是,转到单引号,并在名称周围添加双引号就可以了,例如:

$headers    = 'From: "Bill & Bob, LLC" <ino@billbob.com>\r\n';

现在,我看看它,是有道理的。