Issue
Occasionally, your website's users may not receive emails from your Drupal website. There can be several reasons for this, including the following:
- The Drupal website's email server never initially sends the email.
- The sent email is blocked by an email server or filter before it reaches its intended recipient.
- The intended recipient's email clients discard the email as spam.
Resolution
This article provides information about how to troubleshoot email issues and how you can resolve some of the issues that can occur when sending email from your website.
Modules for testing
When testing your email settings, it's often preferred to do so in a way that does not require emailing all of that environment's users. The following contributed Drupal modules can help you save emails to your logs instead of actually sending emails. The recommended module to do this depends on the version of Drupal you have installed:
-
Drupal 8
Download and install the Helper module, which has a mail handler that writes all emails to the database log. After you install the module, add the following code to your
settings.php
file to use the Helper module's mail handler:<?php $config['system.mail']['interface']['default'] = 'HelperDebugMailLog'; ?>
After you send an email from your website, in the admin menu, go to Reports > Recent log entries to view the email's details.
- Drupal 7
Download and install the Helper module, which has a mail handler that writes all emails to the database log. After you install the module, add the following code to your
settings.php
file to use the Helper module's mail handler:<?php $conf['mail_system'] = array('default-system' => 'HelperDebugMailLog'); ?>
After you send an email from your website, in the admin menu, go to Reports > Recent log entries to view the email's details.
Working with mail server logs
Websites with different hosting providers that can access mail servers can review the server's email log files. These log files are normally located in /var/log/exim4/
and you can use them to ensure both that Drupal sent the email, and that the server accepted the email.
If you don't see any errors in the log file for the email, and if you didn't receive a bounce to the return address (for example, webmaster@domain.com), the email was successfully sent.
Other common issues
My website successfully sent an email, but the recipient never received it. What else can be wrong?
If the email was successfully sent but not delivered to the intended recipient, the problem is usually either that the end user's spam filter caught the email, or that some email server along the path to the user stopped the email (for example, due to overaggressive blacklisting). In this case, try the following:
- Have the intended recipient confirm that the email provider (for corporate users, this could be the IT department) is accepting email that's relayed from your email server.
- If you're seeing error messages (such as
Sender Address Rejected
), examine the Sender Policy Framework (SPF) record. To deal with unwanted email, some email servers refuse email with FROM addresses based on a domain from an unrecognized email server. Email servers use SPF (as defined in RFC 4408) to validate the hosts and domains that are allowed to send email. For more information about SPF records, see the Configuring SPF records for domains [acquia-product:lib] article.
Performance problems from email campaigns
Some email campaigns contain personalized links, so that you can track the number of users who respond to the email and visit your website. This, while valuable for tracking, can cause performance issues. Since each visit in response to the email uses a unique URL, your website will not be able to serve the webpage out of cache. Furthermore, since many visitors are likely to click on the link shortly after receiving the email (if at all), your website is likely to experience a spike in traffic that can't be handled by the cache.
You can avoid these performance issues by not using unique URLs in email campaigns, if possible.