SendCronMailtoGmail

From Wiki

Jump to: navigation, search

Linux boxes like to be able to send mail to notify you of things like failed cron jobs. However, setting up a full-blown mail transfer agent on all of your linux boxen is a bit overkill if all you want is for system mail to be sent to, say, a gmail account. For that, you can use something simple like ssmtp.

Under debian, install ssmtp like so:

apt-get install ssmtp

then edit /etc/ssmtp/ssmtp.conf to look like so:

root=USERNAME@gmail.com
mailhub=smtp.gmail.com:587
UseSTARTTLS=yes
UseTLS=yes
AuthUser=USERNAME@gmail.com
AuthPass=PASSWORD
FromLineOverride=NO

(replace USERNAME and PASSWORD with your gmail account info).

test it out by creating a cron entry. run 'crontab -e' and put this in your crontab:

* * * * * echo foo

wait a minute or two and an email should show up in your gmail account.

once you've verified that it works, run 'crontab -e' again and delete the cron entry.

Personal tools