SendMail Email Server for Registration and Contact in Drupal

By default, Drupal uses php function mail() for sending email that instead uses the sendmail email server. So, in order for your email to work in Drupal you have to make sure the sendmail email server is installed and working on the server

Locate Sendmail

To see if sendmail is already installed and present:

which sendmail

This should return path to the sendmail executable. If it doesn’t then you have to install. If it does, then continue on the Verify Step

Install Sendmail

Here are steps to install and setup sendmail on linux machines:

  1. To install:
    apt-get install sendmail
    
  2. Ensure there is a route to localhost in the local route table
    vim /etc/hosts
    //And make sure the line looks like this:
    127.0.0.1 localhost localhost.localdomain yourhostnamehere
    
  3. To configure the sendmail:
    sendmailconfig
    
  4. Restart sendmail:
    services sendmail restart
    

Verify Sendmail

To verify, an email works with sendmail:

echo "my test email being send" | /usr/sbin/sendmail local@domain.com 

Here, the path to the sendmail executable is specified that you can get by running “which sendmail” command. This sends email to the local@domain.com by sendmail email server.

If you receive the email, then the sendmail email server is working. If you don’t receive the email then troubleshoot as described in next step

Troubleshoot Sendmail

To troubleshoot the sendmail, look at the logs located at /var/log/mail.log or /var/log/mail.err

Registration & Contact in Drupal

First, make sure the admin email is specified with valid email at Site Information(admin/config/system/site-information), otherwise, the email will not be send and you will receive error message such as ‘Connection timed out with example.com.” in mail.logs

To edit current settings on how the registration is handled, go to
admin/config/people/accounts

To configure contact form, go to admin/structure/contact

Troubleshooting

1. Unable to send e-mail drupal

This indicates that sendmail email server is not installed or configured correctly. You can install,configure as described in this post or turn it off for drupal sending email by adding the following line to the php.ini

sendmail_path = /bin/true
2. sendmail[6140]: My unqualified host name unknown; sleeping for retry …sm-msp-queue[6412]: unable to qualify my own domain name

Make sure that the domain name as specified in the error message is in the local route table(in file /etc/hosts) routing to 127.0.0.1.

Connection timed out with example.com.

Ensure the admin email address is configured with a valid email account in Site Information section admin/config/people/accounts

To enable sendmail to use STARTTLS
Resources
  • https://www.drupal.org/node/404190
  • http://holarails.wordpress.com/2013/11/17/configure-sendmail-in-ubuntu-12-04-and-make-it-fast/