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 😉
First of all install the following packages in this exact same order. Otherwise it could fail.
sudo apt-get install exim4-base exim4-config sudo apt-get install exim4-daemon-light sudo dpkg-reconfigure exim4-config
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.
sudo touch /etc/exim4/passwd.client
Add the following lines and save the file
Change firstname.lastname@example.org:password with your e-mail and password.
gmail-smtp.l.google.com:email@example.com:password *.google.com:firstname.lastname@example.org:password smtp.gmail.com:email@example.com: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.
sudo /etc/init.d/exim4 reload
That's all !
You should be able to send e-mails using PHP for example: