SSMTP is a program which conveys email from a nearby PC to a designed mailhost (mailhub). It’s anything but a mail server (like component rich mail server sendmail) and doesn’t get mail, extend nom de plumes or deal with a line. One of its essential uses is for sending robotized email (like framework alarms) off your machine and to an outside email address.
In this post, We will install ssmtp on ubuntu 16.04 and 18.04 LTS
Step 1: Update System
To update the system, You need update and upgrade the ubuntu by using the command.
sudo apt-gte update && sudo apt-get upgrade -y
Step 2: Install SSMTP
After upgrade the system, Now we are ready to install ssmtp by using the command.
sudo apt-get install ssmtp -y
Step 3: Uninstall SSMTP
You need to use the given command to uninstall the ssmtp package from ubuntu machine.
sudo apt-get remove ssmtp -y
Step 4: Configuration of SMTP
Here we are going to confonfigure Gmail’s smtp server with ssmtp, You need to open the ssmtp mail configuration file by using the given command.
sudo vim /etc/ssmtp/ssmtp.conf
Add the following code in the ssmtp.conf file.
root=emailaddresss
mailhub=smtp.gmail.com:587
AuthUser=emailaddress
AuthPass=XXXXXXXXXXX
UseSTARTTLS=Yes
UseTLS=Yes
hostname=localhost
You need to update the credentions with yours, Now save and exit from the vim text editor, Open the another ssmtp conf file by using the given command to configure for email address and smtp address.
sudo vim /etc/ssmtp/revaliases
Add the given code.
root:somebody@gmail.com:smtp.gmail.com:587
Save and exit from the editor, Here our Gmail smtp configuration done.
Step 5: Testing
You need to create a txt file with the following content to verify the sSMTP is working or not, Follow given step for the same.
vim msg.txt
Add the following message.
To: MyEmailAddress@gmail.com
From: MyEmailAddress@gmail.com
Subject: test email
Hello World!
Save and exit from the text editor and lets execute the command to get the email from sSMTP.
/usr/sbin/ssmtp someone@example.com < msg.txt
Conclusion
We have successfully configure Gmail’s smtp with sSMTP in our Ubuntu server.
Get connected with our new devops tools based website- https://www.devopstricks.in/