Having problems sending email using the PHP mail function? Just because you sent an email, doesn’t mean it will arrive!
At JVF we’ve found several limitations when using PHP mail. Our main complaint is that emails sent from a web form ends up in the receivers spam/junk/bulk folders even though we set the correct headers in PHP. We also experienced Gmail users who do not receive the email at all.
If you’re experiencing the same issues, the most important thing to check first is to make sure the SMTP server is not listed in one of the many DNS-based blacklists. Here is the one we have come to trust: MXToolBox
PHP mail uses the settings in PHP.ini to send email through sendmail. Sendmail is a direct path that just hands over the mail you generated to the system’s SMTP server, but requires you to build the header for it. PHP mail does not support SMTP authentication, which is required by many mail servers. Since SMTP requires a valid login to send the mail, the headers match the rDNS records allowing a flawless delivery.
After rigorous testing it’s obvious that PHP mail may be faster since you don’t have to connect to your smtp server, but it’s not better. In the long run, SMTP email is the only way to guarantee that your email will arrive in the inbox of your receivers. So don’t waste your time with the PHP mail function, instead use a web form that requires SMTP logic.