PHP Mail Function vs SMTP Guaranteed Delivery

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.

  • Yeah! I agree with the blog that SMTP is best to send the email in receiver inbox with maximum chances. You can’t get the better result with PHP Email Functions so I would agrees with the writer it would be the long time and energy waste. Thanks for sharing and putting lots of efforts to create this blogs which really help to minimize the confusion in mind.

  • We’ve recently encountered problem where our developer would use PHP Mail and would get inconsistent delivery results. We’re using WordPress and we finally installed this plugin and used SMTP.

  • Hello Garrett, thanks for the post. We too experienced same problems for some of our users. Thanks for the solution.

  • I used php mail function to send mail. But it also failed for my site.

  • Don Knight

    I’ve suspected for a while that sending via SMTP is more reliable than PHP mail(), which is why I use an e-mail toolkit that constructs the e-mail and then sends via SMTP. Could you publish some more details on how you came to your conclusion that SMTP is more reliable than PHP mail()? You’re kind of vague on those points.

  • web development

    Now a days PHP is having more boom compared to other technologies, because of its user friendly functionality.