At your own mail server provided by the web hosting service, where the mail transfer agent (MTA) is normally Exim or Sendmail, there may be email sending and delivery error where emails include those auto-generated by PHP scripts bounce back to the sender’s account by the MTA itself. The problem normally happens during the initial setup of email server, or after you have done some changes to system or web host configuration. And even emails send to well known domains such as Gmail.com, Yahoo.com and Hotmail.com are rejected. The following text message will append to the bounced email:

Mail delivery failed: returning message to sender

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

[email protected]
unrouteable mail domain “hotmail.com”

The unrouteable mail domain error message is a very general error message of mail server which could means a lot of things and possible causes of error. List below is a few common causes and its possible solution.

If you’re using cPanel, the “unrouteable mail domain” error may occur when MTA hit the limit on the maximum number of e-mails sent out per hour. The setting is configured at Tweak Settings section of cPanel WebHost Manager (WHM). Look for the option of “The maximum each domain can send out per hour (0 is unlimited)”. As mentioned, set it to 0 for unlimited emails sending. If you’re using shared hosting, you can change this setting, but you can request support from hosting company or just wait out the hour. This limit is in place to curb any spam attacks that might take place on the servers.

Another possible cause for “unrouteable mail domain” problem when sending mail generated by PHP scripts is the security feature of the web host and Apache HTTPD PHP module. In cPanel, it’s possible to set “nobody” account which Apache is running is not allowed to send emails to remote or external email addresses. If the setting is enabled, the MTA will bounce the e-mails if PHPSuexec or/and Suexec is turned off and disabled. The resolution or solution to this problem is to unselect the “Prevent the user “nobody” from sending out mail to remote addresses (PHP and CGI scripts generally run as nobody if you are not using PHPSuexec and Suexec respectively.)” setting in Tweak Settings section of cPanel WHM. If you’re on shared hosting server and with no access to WHM, again you have to contact the hosting service provider for support and resolution. You can also try to modify the PHP scripts to send emails using SMTP with authentication.

The unable to send email problem may also related to DNS configuration error. The originating mail server for a domain must have an MX record associated with it, which then also need to have a A record in the DNS to resolve to the correct IP address. Beside, Internet Service Providers require all incoming email to be sent from a server with a reverse DNS (PTR) record. All these DNS records must be correctly defined. You can use dig command (for example: dig mx mydomain.com) to verify the MX record, or use third-party websites such as dnsstuff.com and Pingdom DNS check tool to check for all DNS entries.

The sender’s mail server or recipient’s mail server may also has sender verification turns on, in which if the verification fails, you will have some error like below:

Remote SMTP server has rejected address

550-Verification failed for unrouteable mail domain “mydomain.com” Sender verify failed

If it’s your own mail server MTA that’s rejecting the email, you can temporarily turn off “Verify the existence of email senders” in cPanel WHM under Exim or Sendmail Configuration Editor in Service Configuration section. However, the root cause is still related to DNS problem mentioned above as the setting enables check and verify if the MX record of the sender is valid. So if the mail server unable to route the mails to recipients’ MTA and been rejected with the error, you will need to verify the the DNS entries again, although there is slim chance that the receiving mail server is misconfigured.