A Drupal application may need to send email for several purposes, such as password resets, user registrations, or other notifications. Using the SMTP module, you can set up any non Acquia mail infrastructure, such as SendGrid, Mailchimp, or your own mail infrastructure etc.
Configuring the SMTP module
To configure the SMTP module:
Sign in to your Drupal application as an administrator and go to the Admin > Configuration page for the SMTP module.
- In Install Options, select On to turn the module on.
- In SMTP Server Settings, specify the SMTP server and SMTP port.
- In SMTP Authentication, enter the following:
- Username: Your mail infrastructure username
- Password: Your mail infrastructure password
- In Email options, enter a valid from address and a name for the sender of the email (such as your name or your site’s name).
- Click Save configuration.
You can also use encryption with your connection. Instead of the previous values, use the following values in the appropriate places:
- Set the SMTP port to
587 - Set Use encrypted protocol to
Use TLS.
Your Drupal application can now send email through your mail infrastructure.
Many other third party mailing services are available. As always, it is important to do your research and select the one that best integrates with your service needs.
Troubleshooting SMTP connection issues
If your application cannot send email, use these steps to identify if the issue is network-related or configuration-related:
Verify network connectivity:
Before you debug your application modules, confirm that your Cloud Platform environment can reach the server of your email provider. You can test this through thenetcatcommand from an SSH session. For instructions on how to access your environment, visit Managing applications using the command line.
Run the following command, replacing[smtp.provider.com]and[port]with your provider's details. Acquia recommends that you use port 587 (TLS) or 465 (SSL).nc -vz [smtp.provider.com] 587Success: An output similar to
Connection to ... port [tcp/submission] succeeded!indicates the network path is open.Failure:
Connection timed outsuggests a blocked port. If you use port 25, switch to 587 or 465, as many external providers restrict inbound traffic on port 25 to prevent spam. If the system blocks standard ports, check to ensure that your provider supports port 2525 as a fallback.
Check common error signatures:
If the network connection succeeds but emails fail, review your application logs, for example, Drupal Watchdog logs, for these specific error codes:Error Code
Likely Cause
Resolution
535, 535-5.7.8, or Auth Failed
Invalid credentials
Verify the username/password in your module config.
450, 452, 550 (Quota)
Quota exceeded
Check your provider's dashboard, for example, SendGrid, Mailgun, to confirm that you have not hit your daily sending limits.
550 (Relay Access Denied)
Unauthorized sender
Confirm that your sending domain has the correct SPF/DKIM records and that Acquia's IPs are allowlisted by your provider.
Timeout
Port restriction
Switch configuration to port 587 (TLS) or 465 (SSL).