Setup exim4 to use Gmail in Ubuntu

Alright, we’re now going to configure exim4 to use our Gmail account as SMTP Server.

In fact it’s easier than how it sounds 😉

Install exim4

First of all install the following packages in this exact same order. Otherwise it could fail.

The setup will be prompted. Configure as follows

The last command should have prompted a configuration screen. Configure it like this:

  • General type of mail configuration: mail sent by smarthost; no local mail
  • System mail name: (default)
  • IP-addresses to listen on for incoming SMTP connections: 127.0.0.1
  • Other destinations for which mail is accepted: (default)
  • Visible domain name for local users: yourdomain.com
  • IP address or host name of the outgoing smarthost: smtp.gmail.com::587
  • Keep number of DNS-queries minimal (Dial-on-Demand)? No
  • Split configuration into small files? No

Here’s the same configuration but through screenshots. You can skip this and go to the next step if you want.

Create a file

We’re now going to create the file with our Google Account credentials.

Add the following lines and save the file

Change your_email@gmail.com:password with your e-mail and password.

Are you using 2 factor authentication?

If so, you can not use your regular Gmail password, you need an “App Password”.

Go here: https://security.google.com/settings/security/apppasswords then generate a new App password. Use the new generated password in the /etc/exim4/passwd.client file.

Reload exim4

That’s all !

You should be able to send e-mails using PHP for example:

Tags: ,

No comments yet, leave yours!

Leave a Reply

Add <code> Some Code </code> by using this tags.