SSMTP

From Indie IT Wiki

HOWTO: Verbose Logging

Add the following line to /etc/ssmtp/ssmtp.conf

Debug=YES

Then you will see lines like the following in your mail.log file...

Dec 16 11:54:00 mail sSMTP[4985]: Received: by mail (sSMTP sendmail emulation); Sat, 16 Dec 2017 11:53:59 +0000
Dec 16 11:54:00 mail sSMTP[4985]: From: "John Smith" <john@smith.co.uk>
Dec 16 11:54:00 mail sSMTP[4985]: Date: Sat, 16 Dec 2017 11:53:59 +0000
Dec 16 11:54:00 mail sSMTP[4985]: To: john@smith.co.uk
Dec 16 11:54:00 mail sSMTP[4985]: Subject: Test Message
Dec 16 11:54:00 mail sSMTP[4985]: 
Dec 16 11:54:00 mail sSMTP[4985]: This is a test message.
Dec 16 11:54:01 mail sSMTP[4985]: .
Dec 16 11:54:01 mail sSMTP[4985]: 250 Ok 734657345365-5b6fb9c0-5367-4853-9a8b-vde56b-000000
Dec 16 11:54:01 mail sSMTP[4985]: QUIT
Dec 16 11:54:01 mail sSMTP[4985]: 221 Bye
Dec 16 11:54:01 mail sSMTP[4985]: Sent mail for john@smith.co.uk (221 Bye) uid=1000 username=jsmith outbytes=473

HOWTO: Amazon SES

When using Amazon SES collect the information from the SES SMTP settings page.

Then, edit the /etc/ssmtp/ssmtp.conf file...

root=user@example.com
mailhub=email-smtp.eu-west-1.amazonaws.com:465
Hostname=example.com
AuthMethod=LOGIN
AuthUser=[Access Key ID from AWS]
AuthPass=[password from AWS]
FromLineOverride=yes
UseTLS=yes
Debug=YES

Also, update the /etc/ssmtp/revaliases file...

root:user@example.com:email-smtp.eu-west-1.amazonaws.com:465

Thanks - http://edoceo.com/howto/ssmtp

HOWTO: Set Up SSMTP On Ubuntu Server

sudo apt-get install -y ssmtp bsd-mailx
sudo nano /etc/ssmtp/ssmtp.conf
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=me@mypersonalemail.co.uk

# The place where the mail goes. The actual machine name is required no 
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=server1.domain.com:25

# Where will the mail seem to come from?
rewriteDomain=domain.com

# The full hostname
hostname=server2@domain.com

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
# FromLineOverride=YES

AuthUser=myuser@mydomain.com
AuthPass=MyPaSsWoRd
# useSTARTTLS=YES
sudo nano /etc/ssmtp/revaliases
# sSMTP aliases
# 
# Format:       local_account:outgoing_address:mailhub
#
# Example: root:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.
root:server2@domain.com:server1.domain.com:25

http://www.havetheknowhow.com/Configure-the-server/Install-ssmtp.html

Testing

http://askubuntu.com/questions/643873/how-to-get-ssmtp-to-map-local-user-to-email-address-for-the-to-field

echo "message" | mail -s "test" root
echo "message" | mail -s "test" user@domain.com
echo "message" | mail -s "test" -r user@domain.com user@domain.com     (to specify the from address)

HOWTO: Create Aliases

The software SSMTP does not use the traditional file /etc/mail/aliases, but instead uses entries in the file /etc/mailrc.

You will needto install the package bsd-mailx first and make sure the binary 'mail' points to 'mailx'.

sudo apt-get install bsd-mailx
sudo nano /etc/mail.rc

set ask askcc append dot save crt
ignore Received Message-Id Resent-Message-Id Status Mail-From Return-Path Via Delivered-To
alias root root<me@mydomain.com>
alias itsupport user@domain1.com,joe.smith@domain2.co.uk,joebloggs@domain3.com

Thanks - http://possiblelossofprecision.net/?p=591