SSMTP with GMail

From Gentoo Linux Wiki

(Redirected from HOWTO Gmail and sSMTP)
Jump to: navigation, search

Contents

[edit] Installation

To get this running, I followed the documents @ the bottom of this post. Here's the condensed version:

## note that the following just enables mailwrapper in ssmtp 
## this is "to allow multiple MTAs to be installed".  So if one is already using ssmtp one shant need that use flag.
# echo "mail-mta/ssmtp mailwrapper" >> /etc/portage/package.use
# emerge ssmtp

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

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

In /etc/ssmtp/revaliases:

root:youraccount@gmail.com:smtp.gmail.com:587
mainuser:youraccount@gmail.com:smtp.gmail.com:587

[edit] Usage

Install mailx (the package that contains /bin/mail):

# emerge mailx

Test with:

$ mail user@domain.tld
To: user@domain.tld
From: ssmtp@localhost
Subject: sSMTP test

Message body.
<Ctrl+D>

Check the remote account (user@domain.tld) to make sure the mail arrived.

[edit] Troubleshooting

If mail delivery fails ssmtp stores message in ~/dead.letter. You can resend it later using command

$ cat ~/dead.letter | sendmail user@domain.tld

If sendmail is not found, you may need to set a link from sendmail to ssmtp

ln -s /usr/sbin/ssmtp /usr/sbin/sendmail

Take a look to /var/log/messages to get more info (syslog must be installed).

If mail return a "command not found" error, you meed to install mail client like nail (emerge nail). If mail runs but then errors with "/usr/sbin/sendmail command not found" remerge mailwrapper (emerge mailwrapper). Other solution for non existing sendmail command is to recompile ssmtp without mailwrapper flag.

[edit] Resources

[edit] Authors

Personal tools