Installing and Configuring Exim4 for Gmail SMTP Relay

From Fyzix
Revision as of 18:59, 30 July 2019 by Fyzix (talk | contribs) (Created page with "Reference: Reference: R...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search




Create gmail account

Create a gmail account, and be sure to switch Allow less secure apps: ON in the Sign-in and Security Section,


apt-get install -y exim4-base exim4-config exim4-daemon-light libmailutils4 mailutils mutt

Step 1

Run dpkg-reconfigure exim4-config

1. Choose mail sent by smarthost; received via SMTP or fetchmail

2. Type System Mail Name: e.g.

3. Type IP Adresses to listen on for incoming SMTP connections:

4. Leave Other destinations for which mail is accepted blank

5. Leave Machines to relay mail for: blank

6. Type Machine handling outgoing mail for this host (smarthost):

7. Choose NO, don’t hide local mail name in outgoing mail.

8. Chose NO, don’t keep number of DNS-queries minimal (Dial-on-Demand).

9. Choose mbox

10. Choose NO, split configuration into small files

11. Mail for postmaster. Leaving blank will not cause any problems though it is not recommended

Step 2

1. Open the file /etc/exim4/exim4.conf.template

pico /etc/exim4/exim4.conf.template

2. Find the line .ifdef DCconfig_smarthost DCconfig_satellite and add the following in that section

 driver = manualroute
 domains = ! +local_domains
 transport = gmail_smtp
 route_list = *

If you have any other smarthost defined with “domains = ! +local_domains” remove that smarthost.

3. Find the “begin authenticators”. In that section add the following

 driver = plaintext
 public_name = LOGIN
 client_send = : : YourGmailPassword

Make sure you have no other authenticators with the same public_name (LOGIN). Comment them out if needed (Thanks Jakub for reminding me)

4. Find the comment “transport/30_exim4-config_remote_smtp_smarthost”. In that section add

 driver = smtp
 port = 587
 hosts_require_auth = $host_address
 hosts_require_tls = $host_address

Step 3

1. Run update-exim4.conf

2. Do /etc/init.d/exim4 restart or service exim4 restart

That should be it. You can test by using the command line mail client.

Test :

echo "test" | mail -s "subject"

If issues

Nuke and startover.

apt-get -y remove exim4 exim4-base exim4-config exim4-daemon-light
apt-get -y purge exim4 exim4-base exim4-config exim4-daemon-light
apt-get install exim4

Check exim4 queue

exim -bp

Purge exim4 queue

exim -bp | exiqgrep -i | xargs exim -Mrm

Also check this reference out: