Skip to content

Gmail with sSMTP on Deb-based system

2008 October 14
by Philippe Delodder

Before I made the switch to
Google Apps, I had my own mail server but I never had time to made to
switch to something more easyer like sSMTP to replace the mail server.

sSMTP is :

A secure, effective and simple way of getting mail off a system to yourmail hub. It contains no suid-binaries or other dangerous things - no mailspool to poke around in, and no daemons running in the background. Mail issimply forwarded to the configured mailhost. Extremely easy configuration.

In three easy steps I got it running:

Installation:

Step 1: apt-get install ssmtp

Configure 2 files:

Step 2: In /etc/ssmtp/ssmtp.conf, set the following:

root=youraccount@gmail.com
mailhub=smtp.gmail.com:587
rewriteDomain=
hostname=youraccount@gmail.com
UseSTARTTLS=YES
AuthUser=youraccount
AuthPass=yourpasword
FromLineOverride=YES

Step 3: In /etc/ssmtp/revaliases:
root:youraccount@gmail.com:smtp.gmail.com:587
mainuser:youraccount@gmail.com:smtp.gmail.com:587

Done!!!

For more information on sSMTP:

7 Responses leave one →
  1. xlq permalink
    November 19, 2008

    I have tried this over and over again and all I get is “ssmtp: Cannot open mailhub:25″ :(

  2. November 19, 2008

    xlq:

    could you list your config file please?

  3. xlq permalink
    November 19, 2008

    I used exactly the same config file as in the article, except with my own e-mail address and password.

  4. December 28, 2008

    xlq:
    Yes, I see it:
    send-mail: Cannot open mailhub:25
    Can’t send mail: sendmail process failed with error code 1

    That would happen if you set the config file to permissions that did not allow ssmtp to read it.
    In my case, it’s fine if the file is world-readable, but of course I can’t leave it that way since it has my gmail password written right there. When I chmod 600 the config file, ssmtp can’t read it and I get the silly mailhub error you saw. Interesting!

    tai

  5. March 16, 2009

    found your site on del.icio.us today and really liked it.. i bookmarked it and will be back to check it out some more later ..

  6. January 29, 2010

    That would happen if you set the config file to permissions that did not allow ssmtp to read it. In my case, it’s fine if the file is world-readable, but of course I can’t leave it that way since it has my gmail password written right there. When I chmod 600 the config file, ssmtp can’t read it and I get the silly mailhub error you saw. Interesting!

    I ran into the same problem when securing ssmtp. The best resource I’ve found on this subject so far is http://wiki.freebsd.org/SecureSSMTP

    That page is specific to BSD but I think the general idea applies to Linux as well, since they’re both UNIX.

  7. May 25, 2010

    amazing stuff thanx :)

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS

Bad Behavior has blocked 203 access attempts in the last 7 days.