Now, that you have set the RPi to send emails, lets do the next best thing. Setup fetchmail so that we can setup a cron job to run and get us the emails on Raspberry Pi. What can we do with these emails, lots 🙂 (I hope you already have a Raspberry Pi, if not then head over to element14.)
For now, first install fetchmail:
sudo apt-get install fetchmail
and if you are one of the guys who wants easy configuration then :
sudo apt-get install fetchmailconf
If you are using fetchmailconf, then just fire up “fetchmailconf”. You will get a GUI, where you can configure the setting. If not, then you can create a file “~/.fetchmailrc” which should look something like this:
user "" with password "" mda ""
# do not delete the mails on server.
# do not re-write the headers for the mail, get saner headers for the script to process.
# use ssl
Then you already have a working system for sending and receiving mail. Now, you can set the mda in the fetmailrc to a script which can do few things for you. The script below will get a page and mail it to you, if you have the subject as “get” and send “wake on LAN” to desired PC if you have subject as “wol”. Cool 🙂
To get your email working on your raspberry pi, First thing that you should probably do is to set up outgoing emails from your RPi. The easiest way to do so is with ssmtp.
sudo apt-get install ssmtp
Next configure the ssmtp client to send emails using your ISP, open up the file /etc/ssmtp/ssmtp.conf file and make the changes as suggested below:
# Config file for sSMTP sendmail
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
# Where will the mail seem to come from?
# The full hostname
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# We would want this to be on so that we can set the from line
# from scripts as well.
# NO - Use the system generated From: address
Now, check that you can send emails using the command :