Send email from local system: sSMTP

Setting up an entire email server is not required to avail some basic email features. To send email from localhost system, sSMTP i.e. Simple SMTP is enough and installation is also very easy compared to setting up a Mail Transfer Agent.

1. Install
$ sudo apt-get install ssmtp

2. Edit configuration
$ sudo vim /etc/ssmtp/ssmtp.conf

The config file should be updated like this

# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
#root=postmaster
root=sender.email.id@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=sender.email.id@gmail.com
AuthPass=password
UseTLS=YES
UseSTARTTLS=YES

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

# The full hostname
#hostname=kuntal-HP-15-Notebook-PC
hostname=sender.email.id@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

3. Test the setup
$ ssmtp recipient.email.id@gmail.com

Create the mail


To: recipient.email.id@gmail.com
From: sender.email.id@gmail.com
Subject: test subject

Test body.

Enter Ctrl + D

That’s all to get the email in recipient.email.id inbox

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s