Tested on:Raspberry Pi 2; Raspberry Pi B+; Python 2.7; Raspbian pre Jessie
Prerequisites:Raspberry Pi with Raspbian Jessie and internet connection (see steps 1-7 in the Introduction)

Sending emails with the Raspberry Pi

The Raspberry Pi has a plethora of options for communicating with the outhere world. Emails are slow, but information traveling speed is not always important and emails can be read and written on smartphones, which leaves a lot of useful applications. For example, a motion sensor could send an alert when triggered, or you could email your intelligent heating setup half an hour before you’re home…
A tribute to IQjar.com for writing a great tutorial on sending emails! Look into the article for further information and some troubleshooting tips.

Setup send
Type in the terminal

Configure mail server
Open ssmtp.conf with sudo nano /etc/ssmtp/ssmtp.conf. The file must contain

with SSMTP being your email accounts SSMTP server and PORT its port. EMAIL is the email address belonging to the account and the real PASSWORD needs to be entered.

Setup user email permissions
Open revaliases with sudo nano /etc/ssmtp/revaliases. Add an entry for every user which should be able to sent email, at least

with SSMTP, EMAIL and PORT being the same as above.

Python script
Change NAME to the username of the email account, PWD to its password, EMAIL_FROM to the sender adress and EMAIL_TO to the receiving address in the script. Additionally, enter the SSMTP and PORT from the previous step.

Receiving emails
Learn how to scan emails in the Tutorial Scanning Emails with IMAP .

Motion sensor tutorial: http://www.knight-of-pi.org/a-passive-infrared-sensorpir-lets-your-raspberry-pi-detect-motion/
IQjar.com Website: http://iqjar.com
IQjar.com Email Tutorial: http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/
Tutorial Email scanning with IMAP: http://www.knight-of-pi.org/accessing-and-parsing-emails-with-the-raspberry-pi-and-imapclient/

Knight of Pi

Johannes Bergs aka Knight of Pi. Diploma in Bioinformatics, some Webdesign and Python coding then. Living in the beautiful city of Vienna.


Time limit is exhausted. Please reload CAPTCHA.