Easy Outgoing Email

Post date: 22-Jun-2011 20:19:31

Easy Outgoing Mail for Alerts


1) Remove sendmail and install ssmtp

sudo apt-get remove sendmail

sudo apt-get install ssmtp mailutils

2) Link sendmail to the ssmtp binary

sudo rm /usr/lib/sendmail

sudo ln -s /usr/lib/ssmtp /usr/lib/sendmail

3) Edit /etc/ssmtp/ssmtp.conf and enter the details for the following;


# Config file for sSMTP sendmail


# The person who gets all mail for userids < 1000

# Make this empty to disable rewriting.


# The place where the mail goes. The actual machine name is required no

# MX records are consulted. Commonly mailhosts are named mail.domain.com


# For Gmail use: smtp.gmail.com:587

# Where will the mail seem to come from?


# The full hostname


#For Gmail this needs to be turned on




# 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


4) Testing email

Send an email with;

mail -s "test config" root

and check /var/log/mail.log

tail -f /var/log/mail.log

I also updated /etc/ssmtp/revaliases with the current user name

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

#below an example for gmail.


Setting up outgoing aliases

Add the following to /etc/mail.rc

ignore Received Message-Id Resent-Message-Id Status Mail-From Return-Path Via Delivered-To

alias root emailaddress@domain.com