How do I encode PHP pear mail in base64?
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.
精彩评论