How To Configure exim4 on Debian 9

This setup is for a wordpress server that mail-out submissions on the website and assumes that 1) Outbound only. All mail is sent-out via SMTP. You don't want mail retained on the server. 2) there is more than one recipient, re. one for WordPress form submissions and a webmaster (or root). 3) and you are using Google as your SMTP.

First (if using Google for SMTP) login to your Google account and under security settings, enable support for insecure apps.

Then make sure your server is setup accordingly:

sudo vi /etc/hosts

127.0.0.1 localhost
{server ip address} domain.com (do not include the www)
sudo vi /etc/hostname
domain.com (do not include the www)
Reboot the server and check your FQDN
sudo hostname -f

vi /etc/mailname
domain.com (do not include the www)
sudo apt install exim4
sudo dpkg-reconfigure exim4-config
  1. Please select the mail server configuration type that best meets your needs > mail sent by smarthost; no local mail
  2. The Exim SMTP listener daemon will listen on all IP addresses listed here > 127.0.0.1
  3. Please enter a semicolon-separated list of recipient domains > localhost;domain.com
  4. Visible domain name for local users > domain.com
  5. IP address or host name of the outgoing smarthost > smtp.gmail.com::587
  6. Keep number of DNS-queries minimal > No
  7. Split configuration into small files > Yes
Check that your config file looks like the below
sudo vi /etc/exim4/update-exim4.conf.conf

dc_eximconfig_configtype=’satellite’
dc_other_hostnames=’localhost;domain.com’
dc_local_interfaces=’127.0.0.1′
dc_readhost=’domain.com’
dc_relay_domains=”
dc_minimaldns=’false’
dc_relay_nets=”
dc_smarthost=’smtp.gmail.com::587′
CFILEMODE=’644′
dc_use_split_config=’true’
dc_hide_mailname=’true’
dc_mailname_in_oh=’true’
dc_localdelivery=’mail_spool’

Setup SMTP authentication (your Google account)
sudo vi /etc/exim4/passwd.client

gmail-smtp.l.google.com:webmaster@domain.com:password
*.google.com:webmaster@domain.com:password
smtp.gmail.com:webmaster@domain.com:password

Setup the 2 email addresses to receive the appropriate mail. WordPress forms submissions and webmaster.
sudo vi /etc/aliases

mailer-daemon: postmaster
postmaster: submissions@wordpress_website.com
nobody: /dev/null
hostmaster: root
usenet: root
news: root
webmaster: root
www: root
ftp: root
abuse: root
noc: root
security: root
root: webmaster@domain.com

Refresh exim4 aliases

sudo newaliases

Create forward email address for root

Login as root and set forwarding for root
sudo -i
vi .forward
webmaster@domain.com
Restart exim
sudo update-exim4.conf
sudo systemctl restart exim4
Test if exim4 is working
echo "this is a test from domain" | mail -s "Success" webmaster@domain.com
How to force exim4 to send frozen email
exim -bp | grep -i frozen | awk '{ print $3 }' | xargs exim -M
or more simply:
exim -qff


Submit your review
1
2
3
4
5
Submit
     
Cancel

Create your own review

Webmaster Notebook | SELeads
Average rating:  
 1 reviews
by Brad on Webmaster Notebook | SELeads
Thanks

Worked for me thanks

You may also like...