Sender domain policy
If you’ve created a PHP mail form and find it’s not sending email, then it’s most often due to the FROM address the form is using in its headers.
A simple way to confirm if this is the case:
- Log in to your web server via FTP or SSH.
- Navigate to the /Maildir/new folder which is located in your user’s directory:
- In this directory, you’ll see emails that have failed to send.
- Open the emails in a text editor.
- You may see the following error:
Sender domain not allowed. Please read: http://dhurl.org/20b (in reply to end of DATA command))
Why does this happen?
This happens because of the following reasons:
- The outgoing spam prevention policies which were put into effect, as detailed here.
- The FROM address you’re using is not an email address on the domain you’re sending from and/or it’s not hosted with DreamHost.
- For example, if you’re sending from a site called ‘example.com’, the FROM address in your PHP Mail form must be something like email@example.com. Changing this to your email hosted with DreamHost allows the form to send correctly.
If DreamHost is not hosting your email, you must use SMTP authentication to send in your PHP mail form. If you enable SMTP authentication, you can use any email address you like as the FROM address.
Certificate errors using PHP 5.6
In the past, it was possible to use mail.example.com to connect (where example.com is your actual domain name). Due to how modern mail clients handle security, this is now NOT recommended as it may throw connection errors. Please ensure you are only using your mail cluster servername when connecting.
PHP 5.6 handles certificates differently than previous versions as explained on the following page:
When sending via PHP mail, you may see the following errors:
Warning: stream_socket_enable_crypto(): Peer certificate CN=`*.mail.dreamhost.com' did not match expected CN=`mail.example.com'
- PHP SMTP mail
Failed to connect to ssl://mail.example.com:465 [SMTP: Failed to connect socket: fsockopen(): unable to connect to ssl://mail.example.com:465 (Unknown error) (code: -1, response: )]
- WordPress SMTP plugins
The SMTP debugging output is shown below: 2015-09-08 19:44:51 Connection: opening to ssl://mail.example.com:465, timeout=300, options=array ( ) 2015-09-08 19:44:53 SMTP ERROR: Failed to connect to server: (0) 2015-09-08 19:44:53 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
This is due to the hostname being used. The certificate references mail.dreamhost.com which is not same as your domain. View the following article for an explanation of this error:
The solution is to use your mail server's name as the hostname. In the code of your PHP mail form, you are using your domain as the mail servername. It may look something like this:
$mail_host = "mail.example.com";
Instead of using your domain name in the mail server variable, use your actual mail server name. You can find your specific mail cluster in your panel on the (Panel > 'Support' > 'Data Centers') page. View the following article for instructions on how to locate your mail servername.
Update your mail form code using an FTP client or SSH:
In your mail form, change your hostname to the following:
$mail_host = "sub4.mail.dreamhost.com";
Changing the hostname fixes this error. View the following article for further details about mail servernames at DreamHost.