Friday 11 July 2014

SSMTP- Send Mail Easily Through LINUX Terminal (UBUNTU)

Hi,Many of the linux users wish to do everything through terminal (i.e) through commands. This tutorial is mainly for them...

Ways of sending mail from terminal:

There are many ways to send mail from terminal
1.Alpine
2.Mailutils
3.SSMTP
4.Mutt
5.Sendemail

But the ssmtp,sendemail etc can only be used for sending emails.

SSMTP:

Sending mail through ssmtp involves the following steps.

1.Install ssmtp
sudo apt-get install ssmtp

2.Next edit the configuration file.(editor of your choice)
sudo gvim /etc/ssmtp/ssmtp.conf

Here the configuration is done for gmail. Configuring outlook is very difficult. You can try your luck. :)

# Config file for SSMTP sendmail
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=MyEmailAddress@gmail.com

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
#mailhub=mail
mailhub=smtp.gmail.com:587

AuthUser=MyEmailAddress@gmail.com
AuthPass=MyPassword
UseTLS=YES
UseSTARTTLS=YES

# Where will the mail seem to come from?
rewriteDomain=gmail.com

# The full hostname
#hostname=MyMediaServer.home
hostname=MyEmailAddress@gmail.com

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES

4.After configuring you can send mail as shown below:
   This is the command
ssmtp recipient_email@gmail.com

Then it waits for you to enter


To: myemailaddress@gmail.com
From: myemailaddress@gmail.com
Subject: subject
(space to indicate message)
message
<ctrl>d to finish the message.

HURRAH!! message is sent using SSMTP. Meet you in the next knowledge sharing session :)


Author
Ashwanth Selvam
Project engineer

No comments:

Post a Comment