From ArchWiki
Revision as of 16:06, 4 December 2012 by (talk | contribs) (wikify some external links, use https for
Jump to navigation Jump to search
Note: This program still works as of 11-14-2009 but note that SSMTP is no longer being developed. You might want to consider an alternative like MSMTP.
Note: 22 Feb 2010: SSMTP seems to be maintained. SSMTP 2.6.4-1 was put in the Arch Linux packages at 2009-11-26. And in Debian unstable version 2.6.4-3 was put in their unstable repository on 2010-02-09 and move to testing just 10 days later:

SSMTP is a program to deliver an email from a local computer to a configured mailhost (mailhub). It is not a mail server (like feature-rich mail server sendmail) and does not receive mail, expand aliases or manage a queue. One of its primary uses is for forwarding automated email (like system alerts) off your machine and to an external email address.


To install SSMTP:

pacman -S ssmtp

Forward to a Gmail Mail Server

To configure SSMTP, you will have to edit its configuration file (/etc/ssmtp/ssmtp.conf) and enter your account settings:

# The user that gets all the mails (UID < 1000, usually the admin)

# The mail server (where the mail is sent to), both port 465 or 587 should be acceptable
# See also

# The address where the mail appears to come from for user authentification.

# The full hostname

# Use SSL/TLS before starting negotiation 

# Username/Password

# Email 'From header's can override the default domain?

Change the file permissions of /etc/ssmtp/ssmtp.conf because the password is printed in plain text (so that other users on your system cannot see your Gmail password).

chmod 640 /etc/ssmtp/ssmtp.conf

Change the config file group to mail to avoid "/etc/ssmtp/ssmtp.conf not found" error.

chown root:mail /etc/ssmtp/ssmtp.conf

Users who can send mail need to belong to "mail" group (must log out and log back in for changes to be used).

gpasswd -a mainuser mail

Create aliases for local usernames


To test whether the Gmail server will properly forward your email:

echo test | mail -v -s "testing ssmtp setup"

If you receive the error

send-mail: Cannot open mailhub:25

be sure the user is a member of the "mail" group.

Change the 'From' text by editing /etc/passwd to receive mail from 'root@myhostname' instead of just 'root'.

chfn -f root@myhostname root
chfn -f mainuser@myhostname mainuser

Which changes /etc/passwd to:

grep myhostname /etc/passwd

An alternate method for sending emails is to create a text file and send it with 'ssmtp' or 'mail'

Subject: Test

This is a test mail.

Send the test-mail.txt file

mail < test-mail.txt


This method does not work with attachments. If you need to be able to add attachments, install and configure Mutt and Msmtp and then go see the tip at nixcraft.