Send Mail Using SSMTP on Ubuntu

Sunday, October 27, 2013 2 Comments

Send Mail Using SSMTP. Just another log of one of my activities :D

Currently, I set up my desktop computer to be able to send email. Not from browser, but from the system. 

So, I am using ssmtp with a guide from a quite-old-post from Tom Dryer in tombuntu.com. I've set up my laptop before with it, and works. And after a while, I need to set up my desktop, and I forgot, and I got back to Tom's post :D

How To

Well, we need to install SSMTP first
sudo apt-get install ssmtp

then, we need to change the configuration, located in /etc/ssmtp/ssmtp.conf. My configuration is like this :

#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=<your account username>

# 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=smtp.gmail.com:587

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

# The full hostname
hostname=<your account username>

# 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
AuthUser=<your account username>
AuthPass=<user email password>
UseSTARTTLS=yes
UseTLS=yes

Change <your account username> with your email account, for example : account@gmail.com, and <your password> with your email password.

Please note, that above configuration is using gmail. So, if you're using another email provider, just adjust the setting.

And done! Just as simple as that.

Well, if you wanna give it a try, open your terminal, and type 
ssmtp email-recipient@provider.com

Wait for a while, and type the following format
To: email-recipient@provider.com
From: from-who@provider.com
Subject: the-subject

Bla blah blah..

.. and now press Ctrl+D to send the email. It will took a while till the program send the email. Just wait it. Sometimes it seems like not working and just stuck in blinking cursor. But just be patient. :D

So, that's it. Stand by on your inbox! :D

Setting Up Apache/ php.ini to send email

On your php.ini, search for sendmail. If you never set it up before, you'll get this line
;sendmail_path = 

Just uncomment the line by removing the semi-colon sign, and fill with "/usr/sbin/ssmtp -t".

So, the final result will be like this:
sendmail_path = /usr/sbin/ssmtp -t

Save it, then restart the apache (sudo servie apache2 restart) and enjoy :)

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Do you think I forgot to change this text? No, dude. I did it on purpose ahahahay..

2 comments

Write comments
Kika
AUTHOR
January 9, 2014 at 10:44 PM delete

Wuaahh saya nggak ngerti Ubuntu. Belum pernah pakai :D

Reply
avatar
tom
AUTHOR
November 25, 2014 at 5:00 AM delete

Eh? Njenengan becanda kan, Om? :3

Reply
avatar