开发者

How do I encode PHP pear mail in base64?

开发者 https://www.devze.com 2023-02-05 16:27 出处:网络
I\'ve inherited some legacy code that sends e-mail as follows: $headers .= chunk_split(base64_encode($mailbody));

I've inherited some legacy code that sends e-mail as follows:

$headers .= chunk_split(base64_encode($mailbody));
mail("my@email.com", $subject, "", $headers);

It looks strange because it us开发者_StackOverflowes no body, and encodes everything in base64 and puts it in the header. Because I'm hitting limits with the default send mail on my host, I'm switching to SMTP with PEAR's Mail package as follows

$mime->setTXTBody($body);
$mime->setHTMLBody($body);

$mimebody = $mime->get();
$mimeheaders = $mime->headers($headers);

$smtp->send($to, $mimeheaders, $mimebody);

An unexpected consequence is that for some reason gmail is now reporting my messages as spam. How do I get base64 encoding working with php and pear?


You want to prevent your mails getting marked as spam. See How do you make sure email you send programmatically is not automatically marked as spam? for an answer.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号