每当从WordPress站点触发邮件时,邮件内容中的一些字母会随机替换为“=”。我已经在标题中设置了字符集和内容类型,即使这个奇怪的错误即将出现。可能的解决方法是什么?
下面是我触发WordPress站点邮件的代码:
$footerText = "<br/><br/>
Regards,<br/>
ABC<br/><br/>
Note: This is an automated mail. Please do not reply to this message";
$post = get_post($postId);
$post_date = strtotime($post->post_date);
$author_email = get_the_author_meta( \'user_email\', $post->post_author);
$headers = array();
$headers[] = \'Content-type: text/html; charset=UTF-8\';
$headers[] = \'From: \'.FROM_EMAIL;
//$headers[] = \'Bcc: \'.$author_email;
$subject = "Request to share your expertise on - \'".$post->post_title."\'";
$post_title = $post->post_title;
$post_content = $post->post_content;
$post_url = get_permalink($post->ID);
$mail_message = "Your expertise would help solve complex business problems that would
help our associates solve our client problems faster.
Request you to share your expertise on the following post,
which has not been answered for over ".$days." days now.<br/><br/>
Post: <strong>".$post_title."</strong><br/>
Description: ".$post_content."<br/><br/>
Click <a href=\'".$post_url."\'>here</a> to respond to the post.<br/><br/>
Thanks You!
".$footerText;
$hello_text = "Dear Expert,<br /><br />";
$full_message = $hello_text.$mail_message;
wp_mail(\'[email protected]\',$subject,$full_message,$headers);
我使用此代码收到的电子邮件如下:
尊敬的专家:,
您的专业知识将有助于解决复杂的业务p=问题,从而帮助我们的同事更快地解决Cli=nt问题。请你在下面的帖子上分享你的专业知识,这篇帖子已经有8天没有回复了。
职位:RFP for Business De=elopment,Functional Testing,Technology
Expert,Perfecto,Healthcare,Medical =anagement,Mobile,Digital,North
America 这是从数据库检索的动态内容
说明:Customer is asking f=r RFQ to develop a new mobile app
for care management application in AHM. =HM is a subsidary of Aetna
Inc. 这是从数据库检索的动态内容
单击此处回复帖子。
非常感谢。
你好,ABC
注意:这是一封自动邮件=租约不答复此邮件
完全搞不懂为什么随机字母会被替换为“=”。请指出并提出问题所在
SO网友:immazharkhan
在wordpress上的下面链接中,评论两条返回语句并替换它们。org为我工作,现在邮件发送正确,等号“=”问题得到解决。
通过在wp includes\\class phpmailer中进行以下更改进行修复。php
public function encodeQP($string, $line_max = 76)
{
// Use native function if it\'s available (>= PHP5.3)
if (function_exists(\'quoted_printable_encode\')) {
//return $this->fixEOL(quoted_printable_encode($string)); commented this one
return quoted_printable_encode($string); // added this line
}
// Fall back to a pure PHP implementation
$string = str_replace(
array(\'%20\', \'%0D%0A.\', \'%0D%0A\', \'%\'),
array(\' \', "\\r\\n=2E", "\\r\\n", \'=\'),
rawurlencode($string)
);
$string = preg_replace(\'/[^\\r\\n]{\' . ($line_max - 3) . \'}[^=\\r\\n]{2}/\', "$0=\\r\\n", $string);
//return $this->fixEOL($string); commented this one
return $string; // added this line
}
请在此处阅读更多信息:
https://core.trac.wordpress.org/ticket/33815