Tech Tips on Computers, Internet, Blogging, Web Development, Social Media, Android and more

Full width home advertisement

Post Page Advertisement [Top]

drupal-unable-to-send-emails-smtp
In earlier versions of Drupal or for that matter even WordPress, the site could send email notifications easily using the PHP mail function. However, most hosts have disabled the default mail function due to security and vulnerability reasons. Therefore, emails will not go. This is not a Drupal issue as the same  issue we see on WordPress as well. In this post, we shall discuss how to let Drupal site send out emails using a third party module.


If you try to try to do any operation on the Drupal site that requires email to be sent, such as "Forgot password", you may have seen the error displayed by Drupal is as shown below:
"Unable to send email. Contact the site administrator if the problem persists..
Initially, I thought this was a Drupal issue. Then I also encountered similar issue in WordPress CMS sites as well. Thankfully, there are modules and plugins available for both Drupal and WordPress CMS.

In order to let emails work, we need to install a third party module - SMTP Authentication Module. This module allows Drupal to bypass the PHP mail() function and send email directly to an SMTP server. This module solves the problem of Drupal not able to send out emails.

Before configuring the SMTP Authentication module, check your domain's email settings for the username, incoming mail server, outgoing mail server, port requirements, protocols, and whether authentication is required or not.

A) Where to get the SMTP configuration details for your domain email?

If you are not sure where to get the above SMTP details required, you can get the details from the email address setup on your domain Control Panel.
  • For example on CPANEL: Login to CPanel > Email > Open Email Accounts
  • Corresponding to the particular email address in use for the WordPress website, click on "Setup Email Client". A page is displayed showing the SMTP configuration details. Yes, this page is about configuring Email Clients such as Outlook, Thunderbird or Email on your phone, but don't be confused. The requirement is the same.
  • Get those details and put it in the WordPress Mail SMTP plugin configuration page.
cpanel smtp manual setting details

Note the details of your domain email and then proceed with the configuration of SMTP Authentication module on Drupal.


Configuration of Drupal SMTP Authentication Module
 If the SMTP module is not configured propery with required settings, emails will still not be sent by Drupal. The following are working settings I have used on Drupal sites with the SMTP module.

  • Prerequisites: Download , install and enable the Drupal Module - SMTP Authentication Module 
  • Go to Configuration > SMTP Authentication Support

INSTALL OPTIONS
  • Turn this module on or off: ON
Note: To uninstall this module you must turn it off here first and then uninstall the module.
  • Turn on delivery of emails: ON
Note: This should be ON to use the module. As mentioned in the settings page, with this option turned off, email messages will be queued up and processed as normal, but not actually delivered. This option should only be used for testing purposes.
  • Send mail by queue: check or uncheck
If checked, Mails will be sent by drupal queue api. This settings is up to you. In my configuration, this is unchecked.
  • Retry sending mail on error: check or uncheck
If checked, Mails will be added to the queue and sent by drupal queue api on error. If you need the system to retry on error, check it.

SMTP SERVER SETTINGS

For settings in this section, refer to your email settings as per your host as described in A) Where to get the SMTP configuration details for your domain email?" above.
 
  • SMTP server: domainname.com

Enter the domain name as the SMTP server. If the domain name does not work, find out or check with your host for the server name or IP.  In some cases, "localhost" will also works. If you are unsure what to enter here, kindly check with your host.

  • SMTP backup server: NONE
If required, enter the address of your outgoing SMTP backup server. If the primary server can't be found this one will be tried. This is optional.

  • SMTP port: 465, since SSL is used.

The default SMTP port is 25, if that is being blocked try 80. Gmail uses 465.

  • Use encrypted protocol: SSL

This allows connection to a SMTP server that requires SSL encryption such as Gmail. Depends on how your email is configured or to be used as per setting with your web host. If your host allows SSL/TLS, use 465.

If you have any doubts regarding the settings, kindly contact your host for information.

SMTP AUTHENTICATION
  • Username: info@domain.com 
Enter the SMTP username, that is, the email you have with the domain.
    • Password: the password for the email
E-MAIL OPTIONS
  • E-mail from address: info@domain.com
Enter the e-mail address that all e-mails will be sent from. Ideally, use the same email set up at Site Configuration.

  • E-mail from name: some name
This is the name that all e-mails will be from when the receiver sees the email. If left blank will use the site name of the site.
  • Allow to send e-mails formatted as HTML: Optional
SMTP CLIENT SETTINGS
  • Hostname: none
  • HELO: None
END TEST E-MAIL
Enter the email where you want to send a test mail after saving the configuration.
  • E-mail address to send a test e-mail to: enter some email address

  • E-mail address to reroute all emails to: NONE
DEBUGGING AND LOGGING
If you want errors to be logged, enable appropriate settings.

  • Logging: None, Errors only or Log Everything are the options.

Recheck the details entered in the SMTP Authentication Module configuration page and if the settings are alright, click on "SAVE CONFIGURATION".

While the settings are saved, Drupal will send a test email provided. After saving the SMTP module configuration, a system message like this will be displayed:

SMTP.module is active.
The configuration options have been saved.
A test e-mail has been sent to testemail@domain.com. You may want to check the logs for any error messages.
SMTP.module is active. 
If every thing goes well, there should be an email received at the email address provided in test email settings.

drupal-smtp-authentication-module-test-email

If there are errors in sending email, a red notification will also be displayed. You can also check the log.

Error log check:
If there has been an error in sending out emails, you may check the log from the link given in the notification right after saving the configuration. But there are very few details. For more details, you may login to your control panel and check server logs. There may be more details about the issue.

 

    No comments:

    Post a Comment

    Bottom Ad [Post Page]