Sending automated emails which don’t get blocked by ISPs
- Published:
- September 5, 2007 @ 12:38 am
- Category:
- Server Administration, PHP
- Author:
- Chris Wheeler
I’ve recently come across a problem where automated emails are getting blocked by a number of ISPs. I’ve tracked this down to the sender verification methods some ISPs use - If an email comes from an address which isn’t an active mailbox on the server, it is sometimes dropped without any notice to the sender or recipient.
A fair few web sites send automated emails from addresses such as no-reply@domain.com do-not-reply@domain.com forum@domain.com etc - if these accounts are not setup the mails will be discarded by some servers.
You should always use a real email account to send emails - even if it silently discards all incoming mail.
Another problem is that if PHP’s mail() function is being used, and php is running as the userĀ ’nobody’, emails by default will be sent from nobody@hostname.isp.com - which in most cases does not exist.
The way around this is to specify the senders email address through the mail function. e.g.
mail($to, $subject, $body, $headers, '-f sales@domain.com')
Note: Even if you have set the ‘From: ‘ field in the email headers, the email envelope address may still be set to a different account, using the ‘-f email@address’ parameter will fix this, and your emails should reach your customers!