In this article, I'll show you how to make a simple Gmail notifier. Python can do various things in terms of notifications; sending commands to an Arduino unit, playing sounds, opening windows, etc. The code below simply plays some music, but the possibilities of notification methods are endless. If you aren't familiar with python, there are many sites with tutorials like this one, or this one.
- A Gmail account
- Python 2.7 or later, with feedparser installed (get it here)
- A little python experience
For this program, you need two pieces of code. The first one parses your account data and sends it to Gmail, then checks for mail. The second portion runs this program every second, and notifies you when a new email is present. The code I wrote simply plays three notes using winsound (it will only work on Windows computers).
First portion- Parser.py:
import sys, feedparser, winsound
#Here, we import modules needed for this program
#We assign variables with values. Fill in your username and password
email = int(feedparser.parse(
PROTO + USERNAME + ":" + PASSWORD + "@" + SERVER + PATH
#parses your account data and sends it to gmail
if email > 0:
newEmail = 1
newEmail = 0
#checks for mail
#plays sound if email present
Second portion- Checker.py:
import parser2, time
#re-run program to infinity, every ten seconds. Change the "time.sleep(seconds to wait) variable if you want a longer/shorter check interval.
I simply have it playing sound, but it would take all of three seconds to set up an Arduino interface, and in turn, have the Arduino light up a bulb, ring a physical bell, or any number of things. You could even have python speak the email text, or reply to the sender. Use your imagination! :)
Want to start making money as a white hat hacker? Jump-start your white-hat hacking career with our 2020 Premium Ethical Hacking Certification Training Bundle from the new Null Byte Shop and get over 60 hours of training from ethical hacking professionals.