Send email from command line using gmail and ssmtp

This is a very good tool i use to email me of any notifications on my centos box. Plus i use it to send emails when i am working on command line.

If you havent already installed the EPEL i386 Repo, then do
# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

then,
# yum remove sendmail (optional)
# yum install ssmtp

Now, configure the ssmtp.conf file:
# vi /etc/ssmtp/ssmtp.conf
AuthUser=(username)@gmail.com
AuthPass=(your – password)
FromLineOverride=YES
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES

# service sendmail stop ( if not removed above)
# chkconfig sendmail off (if not removed above)
# mkdir /root/.backup
# mv /usr/sbin/sendmail /root/.backup/
# whereis ssmtp
ssmtp: /usr/sbin/ssmtp /etc/ssmtp /usr/share/man/man8/ssmtp.8.gz
# ln -s /usr/sbin/ssmtp /usr/sbin/sendmail
# echo “This is a test email” | mail -s “Test” merocentos@gmail.com
This will send an email to merocentos@gmail.com …..
You can use this on a script,cron and any log messages now to make the centos box email you the issues…. comment on any help needed.

run automatic backup on usb as soon as it’s plugged in

[root@saurap /]# cat /proc/scsi/usb-storage/*
Host scsi27: usb-storage
Vendor: Sony
Product: Storage Media
Serial Number: 2A07060549833
Protocol: Transparent SCSI
Transport: Bulk
Quirks:

[root@saurap saurap]# vi /etc/udev/rules.d/pendrive.rules
#BUS=”usb”, SYSFS{serial}=”2A07060549833″, SYMLINK=”Storage\ Media”, RUN+=”/home/saurap/penback.sh”
OR
SUBSYSTEMS==”usb”, ATTRS{serial}==”2A07060549833″, SYMLINK+=”Storage”, RUN+=”/home/saurap/penback.sh”

Then create the penback.sh script for backup as

vi penback.sh
#!/bin/bash
mount /dev/sdb1 /media/PEN
sleep 3
rsync -zvr /home/saurap/Desktop/mine/ /media/PEN/backup