Let me introduce you to the “extremely simple MTA to get mail off the system to a mailhub”. Particularly useful when you don’t want systems to have a full blown MTA installed. Such as Postfix, Exim or Sendmail. I find ssmtp extremely helpful on standalone servers that use Logwatch.
Getting this up and running requires 4 steps.
- Installing SSMTP
- Configuring SSMTP
- Changing the MTA on your system
Installing the daemon, ssmtp.
Use your favorite package manager, in my example I’ll be using YUM. (Fedora/CentOS/RHEL/Scientific Linux). For Centos/RHEL/Scientific Linux 5.5 or 5.6 you need access to the EPEL repository to install sSMTP. Add EPEL to your system using the following command.
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
You can find eventual new links from http://download.fedora.redhat.com/pub/epel/5/i386/repoview/epel-release.html
yum install ssmtp
Edit /etc/ssmtp/ssmtp.conf with your favorite text editor. I’ll be using nano.
Remove all the entries and replace it with the ones beneath.
root=insert_your_email_address here mailhub=smtp.gmail.com:587 UseTLS=YES UseSTARTTLS=YES AuthUser=your_gmail_username_which_you'll_be_using_to_send AuthPass=password
Changing the MTA
alternatives --config mta
Press the number that equals /usr/sbin/sendmail.ssmtp and you’re done.
I’m testing this using the verbose mode just to be able to see the dialogue with the Google SMTP server.
cat random_file | sendmail -v your_email_address