Book Image

Raspberry Pi Embedded Projects Hotshot

Book Image

Raspberry Pi Embedded Projects Hotshot

Overview of this book

Table of Contents (20 chapters)
Raspberry Pi Mechatronics Projects HOTSHOT
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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

  1. 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
    
  2. We will define the function required to check e-mails:

    newEmail=""
    username="[email protected]"
    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...