Linux / Windows – what’s the difference…

All local mail sent out via external smarthost (Exim4 on Ubuntu 16.04)

Steps to do:
1. First run (start basic exim conf):

sudo dpkg-reconfigure exim4-config

And use these config options:

General type of mail configuration: mail sent by smarthost; received via SMTP or fetchmail
System mail name:
IP-address to listen on for incoming SMTP connections:, ::1
Other destinations for which mail is accepted:

Machines to relay mail for:
IP address or host name of the outgoing smarthost:
Hide local mail name in outgoing mail?
Yes – all outgoing mail will appear to come from your gmail account
No – mail sent with a valid sender name header will keep the sender’s name
Keep number of DNS-queries minimal (Dial-on-Demand)? No
Delivery method for local mail: (I’d recommend Maildir)
Split configuration file into small files? Yes (you need to edit one of the files next)

2. Then run (add authentication credentials):

sudo nano /etc/exim4/passwd.client

And add the following lines for your mail host, and any aliases it has (found through nslookup). Substitute and with the account you want to route mail through):

mail.yourhosting.provider:< email address >:< password >

3. Once you edit the passwd.client file, update exim conf also:

sudo update-exim4.conf

(which will integrate your changes into your Exim4 config)
4. Restart exim – Run:

sudo /etc/init.d/exim4 restart

And make sure that the service stops and starts properly. If the service is unable to restart, something probably went wrong when you edited the passwd.client file.

If Exim4 restarted, go ahead and run (to check exim log in real time):

sudo tail -f /var/log/exim4/mainlog

(to watch the mail logs)
In a different window, send an email from your system to your desired e-mail to test Your config.

mail -s "testsubject" <your email here>

If everything was fine, You should see your testmail in that emails inbox!

5. To be sure, Edit your address rewrite table /etc/email-addresses by running:

sudo echo 'YOUR-USER-NAME:' >> /etc/email-addresses
sudo echo 'YOUR-USER-NAME@localhost:' >> /etc/email-addresses

If any message comes to your Exim4 with a different envelope address, you need to list it too.
(Although choosing “YES” for “Hide local mail name in outgoing mail?” may allow you to avoid this trouble, you risk sending unintended mails such as these sent to “root” to the smarthost.)
6. Check Your local user alias by:

sudo grep yourlocalusername /etc/aliases
exim -bt yourlocalusername

This tests if Your local username is in alias table and route to send emails for your local account
7. Add external e-mail address to Your local account:

sudo nano /etc/aliases

And insert or modify your local account alias to be:

This will now route all Your local account e-mails to (or whatever You chose there..)

To test just enter:

mail -s "testsubject" yourlocalusername

Leave a Reply

Your email address will not be published. Required fields are marked *