Sunday, July 24, 2011

Send Email from Ubuntu to Anywhere

First you need to install ssmtp on you Ubuntu box, which can be done by.


sudo apt-get install ssmtp


Now let us edit the ssmtp configuration file.

sudo gedit /etc/ssmtp/ssmtp.conf


The username and password are fake don't try them it is not my responsibility.
AuthUser=someone@gmail.com
AuthPass=s0m3p@$$w0rd
FromLineOverride=YES
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES


Your Sendmail client should not be running at this point.


You need to have a program called mail installed on your system as well.

sudo apt-get install mailutils
 

echo "THIS is a test" | mail -s "TEST" XYZ@gmail.com

You can check the status of the mail with the help of the exit codes.  If it returns a Zero the program ran fine.

echo $?

No comments:

Post a Comment