User Tools

Site Tools


networking:linux:ssmtp

This is an old revision of the document!


SSMTP

See also Postfix Authenticated Smarthost (Does the same thing without requiring the EPEL repo.)

http://www.linux.com/archive/feature/132006

http://www.squad17.org/node/39

SSMTP is a simple replacement for a full MTA such as Sendmail or Postfix.

  • if you already have Postfix installed (RHEL/CentOS), see the link above
  • no server daemons
  • no running processes
  • lightweight
  • flexible
  • easier than dealing with an MTA
  • be sure all you need is a simple outbound sendmail command replacement

Installation

See also Using the EPEL Repository

Install ssmtp:

yum install ssmtp --enablerepo=epel

On one older system, mdadm depended on sendmail, I had to do this first:

rpm -e --nodeps sendmail

Configuration

For SSL connections on SMTPS port 465:

vim /etc/ssmtp/ssmtp.conf

root=adminuser@yourdomain.com
mailhub=mail.yourdomain.com:465
RewriteDomain=yourdomain.com
#hostname=_HOSTNAME_
FromLineOverride=YES
UseTLS=YES
AuthUser=smtpuser
AuthPass=smtppass
#Debug=YES

:!: If you want to use TLS connections on Submission port 587, you will need to add/change:

mailhub=mail.yourdomain.com:587
UseSTARTTLS=YES
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt   # Optional?

:!: If you don't specify a hostname, SSMTP will query the local machine. Since we are authenticating, the hostname doesn't matter too much.

Test

:!: If desired, enable (un-comment) the debug line, then look in /var/log/maillog.

If desired, install the mail command:

yum install mailx

update-alternatives --config mta

Send a Test Message

echo test | mail -s "testing ssmtp" tester@yourdomain.com

Or with no mail command and no subject line:

echo test | ssmtp -v tester@yourdomain.com

or

echo test | sendmail -v tester@yourdomain.com

tail -f /var/log/mailog

Another Test

cat << EOF >> /tmp/test.eml
From: MyPBX <smtp@MyPBX>
To: Test <tester@yourdomain.com>
Subject: For test only!


EOF

ssmtp -t < /tmp/test.eml

Change the Default MTA

On Centos:

alternatives --config mta
networking/linux/ssmtp.1521130902.txt.gz · Last modified: 2018/03/15 10:21 by gcooper