SMTP for Drupal — site mail that arrives
By default, Drupal sends mail through the web server's PHP mail function: without authentication and without an established reputation. To Gmail and Outlook, such a message is barely distinguishable from spam — account activations and password reset emails that never arrive are the classic complaint.
The clean solution is Drupal's SMTP module. It replaces the default mail transport with a connection to an external SMTP server, without you having to change anything about your other modules or forms. The five fields below are all the module needs.
Why it goes wrong without a relay
A Drupal site is often more than a website: a member portal, an intranet, an application form for an association or a public body. That is exactly where mail is indispensable — someone who registers and gets no activation email gives up, and nobody tells you. The mail does leave, but it is rejected along the way because nothing proves it comes from your domain.
Setting up SMTP in Drupal
Collect your details
Log in to your 2mail account and retrieve your SMTP server, username and password there.
Fill them in inside Drupal
Install and enable Drupal's SMTP module. In that module's settings you switch it on as the mail transport, fill in host, port, encryption, username and password, and set the sender address to your own domain. The module has a built-in test email: send it to an external address at a major provider, not to an address on your own server.
Authenticate your domain
Make sure SPF, DKIM and DMARC are set correctly for your domain, so recipients can verify that the mail comes from you.
Test
Send a test message to an address at a major provider and check that it arrives in the inbox and not in the spam folder.
The fields Drupal asks for
Every platform names them slightly differently, but it is always the same five. The actual values are tied to your account and can be found in your 2mail account — take them from there, so you are sure to use the right ones.
| Field | What you enter |
|---|---|
| SMTP server (host) | The server name from your 2mail account. |
| Port | The port that matches your chosen encryption; your account shows which one. |
| Encryption | TLS. Never send unencrypted — your credentials would otherwise travel in plain text. |
| Username | The SMTP login of your 2mail account. |
| Password | The matching password. Never use the password of an employee's mailbox. |
Which emails Drupal sends
As soon as the relay is set up, all of these run through 2mail — you do not have to configure them one by one.
Pitfalls with Drupal
The module has to actually be the mailer
Drupal can run several mail systems side by side. If the SMTP module is installed but not switched on as the mail transport, everything keeps going through the PHP mail function and nothing changes. Check that first when the test email arrives but real mail does not.
Sender on your own domain
The site email address in the basic settings is used as the sender. Set it to an address on your own domain — the same domain SPF, DKIM and DMARC are configured for. A free address fails DMARC, however correct the SMTP details are.
Configuration export and passwords
If you use configuration management, the SMTP settings travel along in the export. If an import overwrites them with the values of a test environment, your live site suddenly sends with the wrong details. Keep the password out of the export and set it separately per environment.
A different platform?
SMTP is a standard protocol: any system that speaks SMTP — a CRM, an ERP, a custom application or a server — can send through 2mail using the same five fields.