每当从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('abc@gmail.com',$subject,$full_message,$headers);
使用此代码收到的电子邮件如下:
亲爱的专家,
您的专业知识将有助于解决复杂的业务问题,这将有助于我们的员工更快地解决我们的Cli = nt(s)问题。请求您在以下帖子上分享您的experti = e,现在8天内没有得到答复。
发布:RFP for Business De = elopment,Functional Testing,Technology Expert,Perfecto,Healthcare,Medical = aagement,Mobile,Digital,North America这是动态内容,从数据库中检索
描述:客户要求f = r RFQ为AHM中的护理管理应用开发新的移动应用程序。 = HM是Aetna Inc.的补贴。这是从数据库中检索的动态内容
点击此处回复帖子。
谢谢!
问候,ABC
注意:这是一封自动邮件。= lease不回复此邮件
完全混淆了为什么随机字母会被&#39; =&#39;取代。明确指出并提出这个错误
答案 0 :(得分:1)
在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
}