获取553 5.1.8 ...发送者域不存在错误

时间:2014-05-08 17:51:59

标签: php codeigniter email web smtp

我目前正在使用PHP和CodeIgniter框架做一个网站。用户提交表单后,我想自动向管理员发送一封电子邮件,并向刚刚注册的用户发送一封电子邮件。为此,我使用以下代码:

$this->email->initialize(array('mailtype' => 'html', 'charset' => 'utf-8'));
$this->email->to($row[0]['EMAIL']);
$this->email->from('noreply@portail-du-climat.ec.gc.ca', 'Portail du climat');
$this->email->subject('blabla');
$this->email->message('blabla');
$result = $this->email->send();
echo $this->email->print_debugger();

$interestedAdmins = $this->User->getInterestedAdmins($row[0],$this->adminContactList);
$this->email->initialize(array('mailtype' => 'html', 'charset' => 'utf-8'));
$this->email->to($interestedAdmins);
$this->email->from('alerteAutomatique@portail-du-climat.ec.gc.ca');
$this->email->subject('blabla');
$message  = "blabla";
$this->email->message($message);
$result = $this->email->send();
echo $this->email->print_debugger();

不幸的是,通过这样做,我在两次电子邮件发送尝试中都收到以下PHP错误:

A PHP Error was encountered

Severity: Warning

Message: mail(): SMTP server response: 553 5.1.8 ... Domain of sender address noreply@portail-du-climat.ec.gc.ca does not exist

Filename: libraries/Email.php

Line Number: 1553

作为参考,这里是Email.php中的行号1553(来自CodeIgnitor的文件):

if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, "-f ".$this->clean_email($this->_headers['From'])))

我该怎么做才能解决这个问题?

1 个答案:

答案 0 :(得分:3)

它在错误中的含义 - 您的from地址的域名不存在(它既没有A记录也没有MX记录),因此它被拒绝了。

为该子域添加MX和/或A记录,您将全部设置。