Googlemail and sSMTP on CentOS

      3 Comments on Googlemail and sSMTP on CentOS

sSMTP is a very simple and straightforward alternative to big MTAs like sendmail or Exim. Unfortunately CentOS repositories don’t come with it, so you have to fetch it from Fedora’s EPEL repo.

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm

After activating the ‘Extra Packages for Enterprise Linux’ repository, you can install sSMTP:

yum install ssmtp

Configuration is rather simple. Just change the following values in your /etc/ssmtp/ssmtp.conf

# The person who gets all mail for userids < 500
# Make this empty to disable rewriting.
root=youraccount@googlemail.com

# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named mail.domain.com
# The example will fit if you are in domain.com and your mailhub is so named.
mailhub=smtp.googlemail.com:465

[...]

# Set this to never rewrite the "From:" line (unless not given) and to
# use that address in the "from line" of the envelope.
FromLineOverride=YES

# Use SSL/TLS to send secure messages to server.
UseTLS=YES

[...]

AuthUser=YOURACCOUNT
AuthPass=PASSWORD

You can test by sending a mail to user@domain.tld

# echo test | mail -s "testing ssmtp" user@domain.tld

Resources and further reading:
http://www.boristheengineer.co.uk/slug/configuring_ssmtp.htm
http://www.destr0yr.com/article.php/Gmail_and_sSMTP

3 thoughts on “Googlemail and sSMTP on CentOS

  1. Pingback: /dev/blog » ssmtp revaliases, aliases and mail.rc

  2. Pingback: Using ssmtp securely on CentOS « mbrownnyc

  3. avatardt

    Hi
    I am able to send mail using ssmtp by using the cmdline, but only, if I specify the -au and -ap flags with corresponding values.
    The exact same values, as I’ve already specified in the /etc/ssmtp/ssmtp.conf .

    – 1.) This would work:
    ssmtp -au admin@xxyyzz.net -ap “abc 123ZZZ98” -v -t < /root/bin/msg01.txt

    – 2.) This would NOT work :
    ssmtp -v -t < /root/bin/msg01.txt
    – It dies with authentication error:
    [<-] 334 UGFzc3dvcmQ6
    [<-] 535 5.7.8 Error: authentication failed: authentication failure
    ssmtp: Authorization failed (535 5.7.8 Error: authentication failed: authentication failure)

    In my ssmtp.conf I got:
    AuthLogin=Yes
    AuthUser=admin@xxyyzz.net
    AuthPass="abc 123ZZZ98" (<<== notice the embedded space in the password)

    As ssmtp needs to be called from php on the website (contact form), the no. 2.) version would be needed.

    I got sSMTP v2.64 on Ubuntu 15.04 64 Bit ( Linux xyz 3.19.0-33-generic #38-Ubuntu SMP… )

    I just wonder what I'm missing here … since hours. Can't get it working. Would be very glad for some help.
    Thanks a lot.

    Dt

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.