Exactly what it says in the error - your from
address's domain doesn't exist (it has neither an A record nor an MX record), hence it's getting rejected.
Add an MX and/or A record for that subdomain and you'll be all set.
Question
I am currently doing a website using PHP and the CodeIgniter framework. After a user submits a form, I want to send automatically an e-mail to the admin, and one to the user that just registered. In order to do that, I use the following code:
$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();
Unfortunately, by doing this, I get the following PHP error on both e-mail send attempts:
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
For reference, here is the line number 1553 in Email.php (which is a file from CodeIgnitor):
if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, "-f ".$this->clean_email($this->_headers['From'])))
What can I do to resolve this problem?
Solution
Exactly what it says in the error - your from
address's domain doesn't exist (it has neither an A record nor an MX record), hence it's getting rejected.
Add an MX and/or A record for that subdomain and you'll be all set.