Skip to content
Alexander Holbreich
Go back

How to send E-Mails with Exim installed on Linux

Today I’ll show, how to configure email sending with your Debian Linux. The ability to send mails is a very useful feature for every long-running server machine, it’s an easy and common way to notify the administrator in case of any problems.

Here are configuration steps for mail-sending with Exim and Google Mail account (Google Apps accounts work the same way too).

  • first of all, we need to have Exim running. If not installed - install exim4 via:
apt-get update
apt-get install exim4

Configuration should be presented automatically after the installation. However, you can start configuration wizard of Exim every-time with

dpkg-reconfigure exim4-config
  • Answer all questions of the configuration wizard. The important one is.
  • a general type of mail configuration. Choose “sent by smarthost” if you wanna use the ability of e.g. Googlemail account. Then SMTP with dynamic IP would be difficult ;)
  • Provide a System Mail Name: e.g. mycompany.com
  • Provide IP addresses to listen on for incoming SMTP connections

Use 127.0.0.1 if you want only to send emails from the local machine and nothing for other IP’s.

  • Provide Machine handling outgoing mail for this host (smart host): smtp.gmail.com::587 Other parameters are not so important in our use case.

  • Now it’s time to provide credentials of your Gmail account. Therefore you need edit /etc/exim4/passwd.client file. Insert that for Standard or google app account but replace with valid mail and password.

gmail-smtp.l.google.com:[email protected]:yourPass
*.google.com:[email protected]:yourPass
smtp.gmail.com:[email protected]:yourPass
  • Make sure /etc/exim4/passwd.client belongs to user root and group Debian-exim which is normal so on my Debian. If not, run that command:
chown root:Debian-exim /etc/exim4/passwd.client
  • Actualize the whole configuration with:
update-exim4.conf

So now everything should be in place and we are ready for a first test. Simplest console test should be working via:

echo "Server Mail Test Message " | mail -s "Just Test" [email protected]

Watch logs with:

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

when you see something like this everything vent perfect:

2010-02-14 23:00:26 1NgmVu-0007v8-Kt < = [email protected] U=root P=local S=424
2010-02-14 23:00:28 1NgmVu-0007v8-Kt => [email protected] R=smarthost T=remote_smtp_smarthost H=gmail-smtp-msa.l.google.com [72.14.221.109] X=TLS1.0:RSA_ARCFOUR_MD5:16 DN="C=US,ST=California,L=Mountain View,O=Google Inc,CN=smtp.gmail.com"

Appreciate your feedback.


Archived comments (2)

These comments were migrated from Disqus and are no longer accepting replies.

  • Martin Knotek

    2022-02-20 18:38:41 1nLqAT-0000O5-Ew <= root@nasralach U=root P=local S=357
    2022-02-20 18:38:42 1nLqAT-0000O5-Ew H=gmail-smtp-in.l.google.com [2a00:1450:4013:c07::1a] Network is unreachable
    2022-02-20 18:38:43 1nLqAT-0000O5-Ew => [email protected] R=dnslookup T=remote_smtp H=gmail-smtp-in.l.google.com [108.177.127.27] X=TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256 CV=yes DN="CN=mx.google.com" K C="250 2.0.0 OK nc11si7698314ejc.692 - gsmtp"
    2022-02-20 18:38:43 1nLqAT-0000O5-Ew Completed

    Pls do you have an idea what could be wrong? Internet access seems to be OK...

  • AlexH

    Hi, not knowing what you do and a lot has changed. You comment on 12 years old post.

    "[2a00:1450:4013:c07::1a] Network is unreachable"


    maybe your system don't work with IPv6? Some Internet provider dont route it.