Ga naar de inhoud
Home » Exim4 mail naar Google mail server

Exim4 mail naar Google mail server

Raspberry Pi Blog Header

Zorg dat de packages voor exim4 geinstalleerd zijn

sudo apt update
sudo apt install exim4 exim4-config

Create an App Password (results in 16 characters, skip the spaces, it is something like  mwpdfcdbmfvzddmm).

Ground work done, next in line, configure Exim4. Execute

$ dpkg-reconfigure exim4-config

Choose “mail sent by smarthost; received via SMTP or fetchmail” (probably 2nd option)

  • Set to “localhost” for “System mail name:”.
  • Set to “127.0.0.1” for “IP-addresses to listen on for incoming SMTP connections” to refuse external connections.
  • Leave as empty for “Other destinations for which mail is accepted:”.
  • Leave as empty for “Machines to relay mail for:”.
  • Set to “smtp.gmail.com::587” for “IP address or host name of the outgoing smarthost:”.
  • Choose “NO” for “Hide local mail name in outgoing mail?”.
  • Choose “NO” for “Keep number of DNS-queries minimal (Dial-on-Demand)?”.
  • Choose “mbox in /var/mail/” for “Delivery method for local mail”.
  • Choose “YES” for “Split configuration into small files?”.
  • Leave empty for root en postmaster mail

Now take your favorite editor and open /etc/exim4/passwd.client and add at the bottom the file a line in the format smtphost:username:password which represents your environment.

Example: smtp.gmail.com:arjan.ten.hoopen@gmail.com:<generated-app-passwd>)

Now edit the file /etc/email-adresses, add the two following lines:

root:arjan.ten.hoopen@gmail.com
pi:arjan.ten.hoopen@gmail.com

Everything ready to rock and roll, type

$ update-exim4.conf 

Then restart exim via

$ systemctl restart exim4

Test if it all executes as expected with the command:

$ send_test_email <your-normal-emailaddress>

If it does not, you have to dig into it. The exim4 configuration is in /etc/exim4/update-exim4.conf.conf, the logfile of exim4 is in /var/log/exim4/mainlog. Don’t forget to consult your friend El Goog.