Easy Outgoing Email

posted Jun 22, 2011, 1:19 PM by David Cole
Easy Outgoing Mail for Alerts


http://tuxnetworks.blogspot.com/2009/03/mutt-to-remote-smtp-server.html


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.
root=root@domain.com

# 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=smtpserver.domain.com
# For Gmail use: smtp.gmail.com:587

# Where will the mail seem to come from?
rewriteDomain=yourdomain

# The full hostname
hostname=machinehostname
#For Gmail this needs to be turned on
UseSTARTTLS=YES
AuthUser=emailaddress@domain.com
AuthPass=password


# 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


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.
user1:emailaddress@domain.com:smtp.gmail.com:587

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

Comments