Drupal's smtp contrib module is the standard fix for the PHP-mail-goes-to-spam problem. It is small, well maintained, and works with any SMTP-speaking provider. But installing the module is only the first of three steps. Authentication, DNS and content each have to be right for mail to land in the inbox consistently. This guide walks through all three and ends with a placement test.
A newly registered user on your Drupal site receives the confirmation email in their Gmail primary inbox within seconds. Headers show spf=pass, dkim=pass, dmarc=pass. The email is not in Promotions, not in Spam. You have verified this across at least ten seed mailboxes.
Install and enable
From the project root:
composer require drupal/smtp
drush en smtp -y
drush crThen head to Configuration → System → SMTP Authentication Support (URL path /admin/config/system/smtp).
Configure
Install options
- Turn this module on or off:
On. WhenOff, Drupal falls back to the previous mail_system. - Allow to send e-mails formatted as HTML:
Ononly if your templates render HTML. Most Drupal templates use plain text plus optional HTML — leave on unless you know otherwise.
SMTP server settings
- SMTP server: provider host.
- SMTP backup server: optional. Only useful if you have a failover setup.
- SMTP port:
587for TLS,465for SSL. Prefer 587. - Use encrypted protocol:
TLS.
SMTP authentication
- Username and Password: from the provider.
Common provider values:
Postmark
Host: smtp.postmarkapp.com
Port: 587 (TLS)
User: <server API token>
Pass: <server API token>
SendGrid
Host: smtp.sendgrid.net
Port: 587 (TLS)
User: apikey
Pass: <SendGrid API key>
Mailgun
Host: smtp.mailgun.org (or smtp.eu.mailgun.org for EU region)
Port: 587 (TLS)
User: postmaster@mg.yoursite.org
Pass: <Mailgun SMTP password>
Amazon SES
Host: email-smtp.<region>.amazonaws.com
Port: 587 (TLS)
User: <SES SMTP user>
Pass: <SES SMTP password>E-mail options
- E-mail from address: a mailbox on the authenticated domain, e.g.
noreply@yoursite.org. Do not set this to a Gmail / Outlook address — DMARC at the recipient will reject it. - E-mail from name: public brand name.
Save. Then use Send test e-mail at the bottom of the form and check your inbox.
DKIM signs using the provider's key for your domain. That only works if the From address is on your domain and the DKIM record for your domain is published. If the From address is on a different domain than what the provider signs, DKIM does not align and DMARC fails. Set From to a mailbox on yoursite.org and publish DKIM there, not elsewhere.
TLS, ports, firewall
Port 587 with STARTTLS is the modern default. Some legacy hosts only allow port 465 (implicit SSL). Both work, but:
- Port 587 +
TLSuses STARTTLS (plaintext connection upgraded to TLS). - Port 465 +
SSLuses implicit TLS from the first byte.
If the SMTP test hangs: your host blocks outbound SMTP. Container hosts and some PaaS setups do this. Switch to an API-based module (Mailgun, SendGrid) which sends over HTTPS on port 443 — always allowed.
DNS alignment
With the provider receiving mail from Drupal, you still need DNS for authentication. Example for Mailgun:
; SPF
yoursite.org. IN TXT "v=spf1 include:mailgun.org ~all"
; DKIM (Mailgun gives you the key value)
s1._domainkey.yoursite.org. IN TXT "k=rsa; p=MIGfMA0GCSq...AQAB"
; DMARC
_dmarc.yoursite.org. IN TXT "v=DMARC1; p=quarantine; rua=mailto:dmarc@yoursite.org; adkim=r; aspf=r"Resend the Drupal test mail to a Gmail address. Open "Show original". Verify all three: spf=pass, dkim=pass, dmarc=pass. If any one fails, fix it before moving on.
A native Drupal extension is in private beta — schedule placement tests from admin and alert on drops.
Run a placement test
Authentication passes the cryptographic gate. It does not guarantee primary-inbox placement. Gmail may still send your mail to Promotions based on content. To see real placement, run a seed test.
- Open check.live-direct-marketing.online and generate 20+ seed addresses: Gmail, Outlook, Yahoo, Mail.ru, Yandex, GMX, Web.de, ProtonMail.
- Register a new Drupal user with the first seed. Watch the confirmation email land across providers. The panel shows Inbox / Promotions / Spam per address.
- Trigger a password reset for an existing seed account. Re-test. Password resets scan differently than registrations (single link, no marketing content).
- Submit a Webform or Contact form as a seed. Confirm the notification to the admin mailbox.
When to pick a different provider
Provider choice matters more than SMTP-module configuration. A rough heuristic:
- Postmark — best default for low-volume transactional (under 50k/month). Separates transactional and bulk streams, strong shared IPs.
- Amazon SES — cheapest at scale if you are already on AWS. Requires moving out of sandbox mode and a short reputation warm-up.
- SendGrid — robust, if you are comfortable with their IP-pool tiers.
- Mailgun — strong European region option (EU data residency).
- Brevo (ex-Sendinblue) — free tier of 300/day covers small sites at zero cost.
If the SMTP module test works but your placement is bad, switch provider first before deeper debugging. A clean provider on an aligned domain is 95% of the battle.