April 20, 2014

Installing SSMTP on CentOS 5.6

CentOS Logo This tutorial will guide you through installing SSMTP on CentOS 5.6

SSMTP is an extremely simple MTA to get mail off the system to a mail hub. It contains no suid-binaries or other dangerous things – no mail spool to poke around in, and no daemons running in the background. Mail is simply forwarded to the configured mailhost. Extremely easy configuration. WARNING: the above is all it does; it does not receive mail, expand aliases or manage a queue.

Firstly lets install the EPEL repository as SSMTP is not native to CentOS 5.6 base installations.

Install the EPEL i386 YUM Repository

# rpm -Uvh http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

Remove Sendmail as the binaries can conflict.

# yum remove sendmail

Now install SSMTP

# yum install ssmtp

SSMTP is now installed and all that is let is to configure it.

For a really basic installation uncomment and replace with your mailserver and domain details mailhub and RewriteDomain

# cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.orig
# vi /etc/ssmtp/ssmtp.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#
# /etc/ssmtp.conf -- a config file for sSMTP sendmail.
#
# See the ssmtp.conf(5) man page for a more verbose explanation of the
# available options.
#
 
# The person who gets all mail for userids < 500
# Make this empty to disable rewriting.
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 your mailhub is so named.
mailhub=mail.how2centos.com
 
# Example for SMTP port number 2525
# mailhub=mail.your.domain:2525
# Example for SMTP port number 25 (Standard/RFC)
# mailhub=mail.your.domain
# Example for SSL encrypted connection
# mailhub=mail.your.domain:465
 
# Where will the mail seem to come from?
RewriteDomain=how2centos.com
 
# The full hostname
#Hostname=
 
# 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
 
# Use SSL/TLS to send secure messages to server.
#UseTLS=YES
 
# Use SSL/TLS certificate to authenticate against smtp host.
#UseTLSCert=YES
 
# Use this RSA certificate.
#TLSCert=/etc/pki/tls/private/ssmtp.pem
 
# Get enhanced (*really* enhanced) debugging information in the logs
# If you want to have debugging of the config file parsing, move this option
# to the top of the config file and uncomment
#Debug=YES
  • Anonymous

    Thanks so much for this nhttp://www.webpacket.co.zan

  • Cwhitmore

    easy setup. thanks.

  • http://twitter.com/Mc_Flea Shaheen McLean

    If you want to use sSMTP to use Gmail/Google Apps as the relay host for yourdomain.com, use the following config:

    mailhub=smtp.gmail.com:587
    RewriteDomain=yourdomain.com

    FromLineOverride=YES (uncomment this line)

    UseSTARTTLS=YES (do not use UseTLS=YES which is the default, there’ll be errors)

    AuthUser=user@yourdomain.com
    AuthPass=YourPasswordGoesHere

    If you’re using a PHP mail wrapper set this line in your /etc/php.ini:
    sendmail_path = /usr/sbin/ssmtp -t