Configuring ssmtp
Home Up Configuring cron Configuring ssmtp

 

Configuring ssmtp

Installing ssmtp:

root@zebidee:~# ipkg install ssmtp
Installing ssmtp (2.61-r6) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/slugos-bag/cross/3.10-beta
/ssmtp_2.61-r6_armeb.ipk
Installing libssl0.9.7 (0.9.7g-r1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/slugos-bag/cross/3.10-beta
/libssl0.9.7_0.9.7g-r1_armeb.ipk
Configuring libssl0.9.7
Configuring ssmtp
update-alternatives: Linking //usr/sbin/sendmail to /usr/bin/ssmtp
root@zebidee:~# 

ssmtp needs a bit of configuration to ensure it sends the mail somewhere sensible. Its configuration file is located in /etc/ssmtp/ and is called ssmtp.conf and looks like this:

ssmtp.conf

#
# /etc/ssmtp.conf -- a config file for sSMTP sendmail.
#
# The person who gets all mail for userids < 1000
root=postmaster
# 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 you mailhub is so named.
mailhub=mail
# Where will the mail seem to come from?
#rewriteDomain=localhost.localdomain
# The full hostname
hostname=localhost.localdomain

Hostname

The hostname is supposed to be the full name of the machine sending the mail. For plusnet it's <your account name>.plus.com 

The hostname is supposed to match your reverse DNS name, though it's usually not essential. 

Rewritedomain

"rewritedomain" is the domain name that is added to a local username to turn it into a full email address e.g. "<username>@<rewritedomain>" . If it is commented out ssmtp will set this to the hostname instead.

Root

The root alias is the email address that the mail is sent to by default (though not necessarily the address that will appear in the To field).

ssmtp can be called with a full email address, in which case it will always send the email to that address with no modification.

ssmtp can also be called with just a local username as the destination. If you only supply ssmtp with a username then ssmtp will look for the root alias to find the actual email address to send to. If the root alias only contains a username then ssmtp will add the rewritedomain to make a full email address. 

I've checked and the SlugOS "ssmtp" does use the supplied username as destination for a userid above 999, for example the "nobody" user. Also you can comment out the root line in which case ssmtp will construct the "to" address from the current username (for cron it's always "root").

Mailhub

The mail hub is the machine that you use to send the mail, this would normally be your ISP's "SMTP server". For plusnet that is relay.plus.net

It's possible to pass mail to a local machine if you are running a LAN with a mailserver, however if you are running a mailserver you'll probably know far more about email than I do.

revaliases

The revaliases file defines what will appear in the "from" field of the email.

It's a good idea to set up an alias to force the "From:" line to a sensible value so edit the revaliases file:

# 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.

You can add lines for each username that you intend to use. Note that since cron runs as root all reports from cron are addressed from user "root". Set the root's email address to a valid address as if a message bounces this is where it will end up.

You need to specify the mailhub again here.

ssmtp.conf continued...

# 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

FromLineOverride

I don't know what this one does, it doesn't appear in the SlugOS ssmtp.conf but it turns up in other versions on the net.