Send SMTP email from Command Line Linux / SSMTP / GMAIL
Dear All,It is not possible that on every Single System there is mail server available.
There is no mail server configured on your System and You want to send e-mail using SMTP Authentication then you can send mail by ssmtp utility.
You can use the Same Method for RHEL / CentOS / Fedora / Ubuntu.
So In this Article, I will show you that How can can send e-mail using Gmail Authentication using SMTP.
In this Article, We will use utility called SSMTP.
SSMTP RPM / DEB / Package Must be installed to Use this utility.
To Perform this HowTo :-
Step 1. You have to be root to Install and Perform this Howto.
Step 2. Open the ssmtp.conf in /etc/ssmtp/ssmtp.conf and Add the Following lines as per your requirement.
[root@linux-support-tejas-barot-ahmedabad ~]# vim /etc/ssmtp/ssmtp.confAdd the Following Configurations to /etc/ssmtp/ssmtp.conf and SAVE and EXIT
root=smtpauth@gmail.com mailhub=smtp.gmail.com:587 AuthUser=smtpauth@gmail.com AuthPass=P@ssw0rd UseSTARTTLS=yesStep 3. Now Let’s say Now You want to send a Particular message. Like :-
Subject will be “Check the Server Health” and Body will be your “Cannot Access Server“.
So For the same Create a File called /root/message.txt and Add Following content to file :-
[root@linux-support-tejas-barot-ahmedabad ~]# vim /root/message.txt Subject: Check the Server Health Cannot Access ServerStep 4. Now to Send an e-mail Execute Following command :-
Syntax is ssmtp -vvvv recipientmail@domain.com < <message-file>
[root@linux-support-tejas-barot-ahmedabad ~]# ssmtp -vvvv recipient@domain.com < message.txtThat’s IT
No comments:
Post a Comment