sSMTP is an extremely simple, resource conserving, smtp server that will allow your desktop or server to send email. in this article we are going to use sSMTP to send outgoing email through gmail.
1、Install sSMTP.
Unfortunately,ssmtp is not in CentOS 5 yum base repository,so we have to download and install it manually.
#wget ftp://ftp.muug.mb.ca/mirror/fedora/epel/5/x86_64/ssmtp-2.61-11.8.el5.x86_64.rpm
#rpm -Uvh ssmtp-2.61-11.8.el5.x86_64.rpm
2、configure sSMTP
First,backup and empty /etc/ssmtp/ssmtp.conf
#/bin/cp /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.OLD
#> /etc/ssmtp/ssmtp.conf
#vi /etc/ssmtp/ssmtp.conf
root=sender@gmail.com
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES
RewriteDomain=
Hostname=sender@gmail.com
AuthUser=sender@gmail.com
AuthPass=password
FromLineOverride=YES
add content above,save and quit.
Second,add each account that you want to be able to send mail from by editing, ‘/etc/ssmtp/revaliases’:
#echo ‘root:sender@gmail.com:smtp.gmail.com:587’ >> /etc/ssmtp/revaliases
Please replace sender and password with your Gmail accountname and password.
Third,backup old sendmail
#/bin/mv /usr/sbin/sendmail /usr/sbin/sendmail.OLD
#ln -s /usr/sbin/ssmtp /usr/sbin/sendmail
On my system,sendmail is provided by postfix.
3、Now try sending an email
You can send an email through your favorite email client, like ‘mail’, or type:
ssmtp someemail@email.com
You will then type your message, hit enter and ‘ctrl+d‘
Now that you have a simple outgoing email server setup, you can do all sorts of neat things:
Configure cron jobs to send log reports to your email address
Alert you of all kinds of system changes
Send email alerts when your computer reaches a certain temperature
Send email through PHP, Python, Ruby, and Perl
References:
http://topo.72pines.com/2009/02/18/linux-命令行下用-gmail-smtp-发信/
http://blog.rogerz.cn/archives/599
http://www.nixtutor.com/linux/send-mail-with-gmail-and-ssmtp/