Configure Exim4 to Send Email Through a Password Protected Relay Host

After installing exim4, run

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: <your hostname>
  • IP-address to listen on for incoming SMTP connections: 127.0.0.1
  • Other destinations for which mail is accepted: <your hostname>
  • Machines to relay mail for: <leave this blank>
  • IP address or host name of the outgoing smarthost: mail.example.com::587
  • 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: <choose the one you prefer>
  • Split configuration file into small files? Yes (you need to edit one of the files next)

Then run

sudo gedit /etc/exim4/passwd.client

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

mail.example.com:<email address>:<password>

Once you edit the passwd.client file, run

sudo update-exim4.conf

which will integrate your changes into your Exim4 config.

Run

sudo /etc/init.d/exim4 restart

and make sure that the service stops and starts properly.

So, type that to test,

echo "Testing." | mail -s Test example@gmail.com

Leave a Reply