Zend_Mail sent email is treated as SPAM

空扰寡人 提交于 2019-12-18 16:55:30

问题


Please tell me what I am doing wrong. I am sending an email using the Zend_Mail class like this:

$message = <<<STR
You have a new invoice!

Sign in to your clientarea to see it.

Best regards,

Company name
STR;

$mail = new Zend_Mail();
$mail->setBodyText($message);
$mail->setFrom('billing@company.com', 'Company.com');
$mail->addTo('client@email.com', 'Client Name');
$mail->setSubject('You have a new invoice!');
$mail->send();

It is received as a spam though. There are other applications such as Webmin on my server and emails they send is not treated as SPAM.


回答1:


I have solved this by adding these lines:

$mail->setReplyTo('contact@company.com', 'Company');
$mail->addHeader('MIME-Version', '1.0');
$mail->addHeader('Content-Transfer-Encoding', '8bit');
$mail->addHeader('X-Mailer:', 'PHP/'.phpversion());

The critical line seems to be adding Reply-To header. Without that it would always go to SPAM. Once I set the Reply-To header email clients stopped treating it as spam.



来源:https://stackoverflow.com/questions/3692100/zend-mail-sent-email-is-treated-as-spam

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!