Sending Mails with own Exim: Google account example.

Today I’ll describe short, how to configure sending of emails with your Debian or other Linux distribution. The ability of sending mails is very useful feature for every long-running server machine, it’s easy and common way to notify the administrator on problems.

Here are configurationsteps for mail-sending with Exim and Googlemail account (google Apps accounts work the same way too).

  1. first of all we need working Exim. If not installed – install exim4.
    $ apt-get update
    $ apt-get install exim4
    
  2. Configuration should start after the installation. However you can start configuration of exim every-time with
    $ dpkg-reconfigure exim4-config
    
  3. Answer the questions of 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 ;)
  4. answer other questions
    • Provide a System Mail Name: e.g. mycompany.com
    • Provide IP addresses to listen on for incoming SMTP connections
      User 127.0.0.1 if you don’t want only send mail from local machine and nothing for all IP’s.
    • Provide Machine handling outgoing mail for this host (smarthost): smtp.gmail.com::587

    Other parameter are not so important for a start. However read more about debconf questions and other configuration if you like.

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

    gmail-smtp.l.google.com:yourYourMail@googlemail.com:yourPass
    *.google.com:yourYourMail@googlemail.com:yourPass
    smtp.gmail.com:yourYourMail@googlemail.com:yourPass
    
  6. 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
    
  7. Actualize the whole configuration with:
    $ update-exim4.conf
    

    Your ‘re done!

Now it’s test it with.

echo "Server Mail Test Message " | mail -s "Just Test" SomeMail@someDomain.org

Watch logs:

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

When you see something like this. Everything should vent perfect.

2010-02-14 23:00:26 1NgmVu-0007v8-Kt < = root@mail-server1.mycompany.com U=root P=local S=424
2010-02-14 23:00:28 1NgmVu-0007v8-Kt => testMail@mycompany.org 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"

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • BlinkList
  • MisterWong.DE
  • Slashdot
  • StumbleUpon
  • Technorati
  • NewsVine
  • Reddit
  • Yigg
  • HackerNews
  • LinkedIn
  • Webnews.de
  • Yahoo! Buzz

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

No comments yet.

Leave a comment

(required)

(required)