Monday, September 7, 2020

How to install and configure sSMTP on CentOS

 sSMTP is alternative to Sendmail. which is send the mail from existing mail server like gmail, yahoo or own server. This program to send mail via standard or /usr/bin/mail useragents. it is used to send mail to external mail addr after authentication with account It's also use in nagios, install in nagios server and add the admin email address entry in Contact.cfg file.

1. First step : Install sSMTP Packages :

# yum -y install ssmtp


2. Now we will edit the ssmtp configuration file.
# cd /etc/ssmtp

Here is the custom configuration(here we use gmail account)
# vim /etc/ssmtp/ssmtp.conf

root=**********@gmail.com  
            ## Redirect mail for root@ to postmaster@

MailHub=smtp.gmail.com:587 ## SMTP server hostname and port
AuthUser=*****@gmail.com   ## Your DreamHost mailaccount
AuthPass=        ## The password for the mail account
UseSTARTTLS=YES            ## The password for the mail account

UseTLS=NO                  # Secure connection (SSL/TLS)
FromLineOverride=YES       # Force the From: line
Hostname=mail.gmail.com    # The name of this host
RewriteDomain=mail.gmail.com 
            # The host the mail appears to be coming from

## Compulsory field.

3. If you would like to change the “From“Display Name, edit the /etc/passwd and modify the user alias
# vim /etc/passwd 
user1:User1:507:507::/home/user1:/bin/bash

Note :Before we start using sSMTP need to stop the sendmail.
# service sendmail stop
# sudo chkconfig –levels 2345 sendmail off

4. Move or replace the sendmail and thencreate a symbolic link for sSMTP to sendmail with authentication.
# mv /usr/sbin/sendmail/usr/sbin/sendmail.ori
# ln -s /usr/sbin/ssmtp/usr/sbin/sendmail

5.Now it's time to test sSMTP.

# echo”Sending Test mail to external & Internal email address”|
 mail -s”this is the test msg using sSMTP” testssmtp@gmail.com