admin管理员组文章数量:1405299
I am trying to send email via wp_mail()
containing both plain text, as well as HTML body.
When I am setting up headers like this:
$headers = "MIME-Version: 1.0 \r\n";
//$headers .= "From: Dawid Adach\r\n";
$headers .= "Reply-To: [email protected] \r\n";
$headers .= "X-Mailer: PHP/" . phpversion() . "\r\n";
//$headers .= "To: ".$email."\r\n";
$headers .= "Content-Type: multipart/alternative;boundary=" . $boundary . "\r\n";
and later on content:
//Plain text body
$message .= "Hello,\nThis is a text email, the text/plain version.
\n\nRegards,\nYour Name";
$message .= "\r\n\r\n--" . $boundary . "\r\n";
$message .= "Content-type: text/html;charset=utf-8\r\n\r\n";
//Html body
$message .= '
<!--my html comes here -->
</div>
';
$message .= "\r\n\r\n--" . $boundary . "--";
It doesn't work. The entire body is treated like a plain HTML. When I check an original message I can see that new line chars aren't interpreted correctly.
Reply-To: [email protected] X-Mailer:PHP/7.0.8Content-Type:
multipart/[email protected]; ,
[email protected]
Second thing is that when I try to set header "From: " wp_mail
returns 0 and doesn't send anything.
I was going trough Sending multipart (text/html) emails via wp_mail() will likely get your domain banned , however I cannot overwrite wp_mail function so I have to use original one.
本文标签: plugin developmentwpmail() headers multipartalternative
版权声明:本文标题:plugin development - wp_mail() headers multipartalternative 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744909609a2631833.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论