In this task, we will review setting up e-mail alerts from Gmail accounts. We can blink an LED (as shown in this step) or flash the RGB LED strip (this has to be executed by the reader) when an e-mail of a specific category is received (for example, work e-mail).
We will get started by installing the python-feedparser
tool. Google provides a read-only inbox feed and we will make use of the feedparser
module to determine whether we received any new e-mails.
sudo apt-get install python-feedparser
In order to log in and parse through the e-mail feed, we get started by importing the
feedparser
module:import sys import feedparser
We will define the variables, including the Gmail username and password (changed to generic names below) along with the function that retrieves all unread e-mails. Refer to the following example: