PHP mail() vs SMTP: what's the difference? Print

  • 0

Websites can send email (contact forms, order confirmations, password resets) in two ways.

PHP mail()

The website hands the message straight to the server's mail system. It's simple, but the email isn't tied to a real mailbox and isn't authenticated, so it's more likely to be marked as spam, especially if the From address is on another domain such as Gmail.

SMTP (recommended)

The website logs in to a real mailbox, exactly like an email app, and sends through it. Messages are authenticated and pass SPF/DKIM checks, so they're far more likely to arrive.

How to switch to SMTP

  • WordPress: use a plugin such as WP Mail SMTP (see How to send WordPress emails via SMTP)
  • Custom PHP: use a library such as PHPMailer with your mailbox settings: server hostname, port 465 (SSL) or 587 (TLS), full email address and password

Always send from an address on your own domain that exists as a mailbox.


Was this answer helpful?

« Back