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.

SMTP Mail

SMTP Mail

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.conf 

Add 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=yes

Step 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 Server

Step 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.txt

That’s IT

Hope this will helps you all, If you face any issue regarding the same or its not working for your some how then please raise your questions / issues at http://linuxforums.tejasbarot.com

If you like this then Please Click Google +1 Button and Show Your Support. Your Support will encourage me to write more articles.

Ask for Linux Commercial Support :- http://www.tejasbarot.com/linux-commercial-support/

All Linux User’s Blog Mobile Applications :- http://www.tejasbarot.com/download-mobile-apps/

Please Keep in Touch with Social Networking :- 

Facebook :- https://www.facebook.com/tejasbarot.official

Facebook Page :- https://www.facebook.com/AllLinuxUsersBlog

Twitter :- https://www.twitter.com/imtejasbarot

LinkedIn :- http://in.linkedin.com/in/imtejasbarot

Enjoy SMTP :) Enjoy SSMTP :) Enjoy Open Source :) 

Content Protection by DMCA.com

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


1 Comment »

 
  • Talha says:

    Thanks for useful information.
    I’d like to learn that is it possible to define variables(like system variables or command arguments) inside ?

 

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


nine − = 6