电子邮件在蛋糕php中发送垃圾邮件

时间:2012-06-05 09:27:18

标签: cakephp cakephp-1.3 sendmail

以下是我的代码: -

//Sending mail
if ($this->Session->read('Enrollment.personalinfo_language') == 'English') {
    $language = "english";
    $subject = "Thank you for submitting your enrollment request to Apna Energy.";
} else {
    $language = "spanish";
    $subject = "Gracias por enviar su solicitud de inscripci?n a Apna Energy.";
}
$details = $this->Session->read('Enrollment');
$details['plan_name'] = $product['Product']['name'];
$details['rate'] = $plan_rate;
$details['term'] = $product['Term']['term'];
$this->Email->sendAs = 'html';
$this->Email->from = 'Apna Energy <contact@apnaenergy.com>';
$this->Email->to = $this->Session->read('Enrollment.personalinfo_first_name') . ' ' . $this->Session->read('Enrollment.personalinfo_last_name') . '<' . $this->Session->read('Enrollment.personalinfo_email') . '>';
$this->Email->bcc = array('my@mail.com');
$this->Email->subject = $subject;
$this->set('details', $details);
if ($this->Session->read('Enrollment.personalinfo_language') == 'English') {
    $template = "enrollment_confirmation";
} else {
    $template = "enrollment_confirmation";
}
$this->Email->template = $template;
$this->Email->send();

我的问题是,如果客户填写表格,他们在他/她的垃圾邮件文件夹中接收邮件..客户的邮件ID在“to”..我的邮件ID在“BCC”中为我邮件在我的收件箱文件夹中正常。

我关注了两个网址,但他们没有为我工作..

Cakephp emails going to spam

How do you make sure email you send programmatically is not automatically marked as spam?

指导我正确的方向.. 谢谢!

1 个答案:

答案 0 :(得分:1)

使用SMTP

使用普通PHP,您的服务器必须正确配置,这对初学者来说并不容易(MX记录需要匹配服务器ip等)。 所以,只要始终坚持使用SMTP作为邮件网关,你就可以了。

PS:我认为它与你的代码一般没有任何关系,虽然它不是很漂亮。例如:你应该转换你从会话中读取的数组,以避免引发通知:

$details = (array)$this->Session->read('Enrollment');