Setting up the e-mail feed parser
In this task, we will learn to set up an e-mail feed parser and blink an LED. As an example, we will check new e-mails in a Gmail account.
Prepare for lift off
Since we already installed the python-feedparser
module, we will get started with setting up the mail parser. We will build each module of our project as a separate example.
Engage thrusters
Using Python IDLE, let's get started with writing a python script to achieve this task. We will get started by importing the
feedparser
module:import sys import feedparser
We will define the function required to check e-mails:
newEmail="" username="username@gmail.com" password="password" proto="https://" server="mail.google.com" path="/gmail/feed/atom" def mail(): email = int(feedparser.parse(proto+username+":"+password+"@"+server+path)["feed"]["fullcount"]) return email
Note
The preceding function has been borrowed from the WonderHowTo website (http://null-byte.wonderhowto.com/how-to/make-gmail-notifier-python...