Overview
This article explains how to send PHP mail using an SMTP program instead of the default PHP mail function. Using SMTP helps improve email deliverability and avoids common issues like missing or improperly configured FROM addresses.
Background
When you use the PHP mail function it sends emails directly from your web server, which can cause deliverability issues, especially if the FROM address is not set correctly or if your email is hosted elsewhere. For more information, see the PHP mail troubleshooting article for further details.
Using SMTP with PHPMailer
Sending email via SMTP is recommended because it uses a dedicated mail server, rather than the web server, to send email. This improves reliability and reduces the chances of your messages being marked as spam.
DreamHost recommends using PHPMailer to send email via SMTP. PHPMailer is a popular library for sending email securely and efficiently. It integrates easily with Google’s SMTP servers and provides extensive documentation. See the following articles for more information: