Sending emails from Drupal-powered sites. Setting up Exim under Debian

Submitted by admin on Thu, 10/05/2017 - 13:47

Once you have the web server set up and running, you need to make sure your Drupal site can send emails, like registration confirmation, password change etc.

For inbound email, you may want to use email services like that offered by Google Apps. They offer good spam protection and secure storage.

To send email from a Drupal-powered site, you can use an SMTP module and do it all through a third party mail service. Alternatively, you can set up your own SMTP server. This article describes setting up an Exim server that allows sending emails.

Exim installation and set up

aptitude install exim4
dpkg-reconfigure exim4-config

Once you run the commands, you get a wizard asking you a number of questions.

General type of mail configuration: internet site; mail is sent and received directly using SMTP
System mail name: Reverse DNS for server’s IP, (e.g., drupal-admin.com )
IP-addresses to listen on for incoming SMTP connections: 127.0.0.1
Other destinations for which mail is accepted: domain name we plan to send emails from. You can enter a number of domains separated by spaces.
Domains to relay mail for: leave empty
Machines to relay mail for: leave empty
Keep number of DNS-queries minimal (Dial-on-Demand)? No
Delivery method for local mail: Maildir
Split configuration into small files? No.

 

After that we can run the following command to check if everything is fine:

echo "This is a short email" | mail -n -s "Sending email" address@mail.com

Replace address@mail.com with your actual address and check the inbox, you are supposed to receive an email with "Sending email" as the subject and "This is a short email" as the body.

You may want to contact your hosting provider and ask them to change server name and Reverse DNS to the domain name you send emails from. This allows landing more email in the inbox and not spam folder.

Changing Drupal settings

To make Drupal put your desired address into the From field, you need to specify that address in the site’s settings at [your domain]/admin/config/system/site-information

 

Add new comment

Filtered HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.