Last month I came across an idea to check my email inboxes using python. I did some research on the web and try to imitate the great solutions from other coders. Because I am currently using IMAP service in my main email accounts, I chose to use the “imaplib” module to achieve my expectation. Here are the codes:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#!/usr/bin/python #-*- encoding: utf-8 -*- import imaplib import re def gmail_checker(mailhost, username, password, flag = 0): i=imaplib.IMAP4_SSL(mailhost) try: i.login(username, password) x, y=i.status('INBOX', '(MESSAGES UNSEEN)') messages=int(re.search('MESSAGES\s+(\d+)', y[0]).group(1)) unseen=int(re.search('UNSEEN\s+(\d+)', y[0]).group(1)) print "-------------------------------------------------" print "%s : total %i messages, %i unseen." % (username, messages, unseen) finally: i.logout() if __name__ == '__main__': gmail_checker('imap.163.com', 'xxxx@163.com', 'xxxx', 1) gmail_checker('imap.qq.com','xxx@qq.com','xxx',1) gmail_checker('imap.gmail.com', 'xxx@gmail.com', 'xxx',1) gmail_checker('imap-mail.outlook.com', 'flyws1993@hotmail.com','xxx', 1) |
I needed this to help me because in China is kind of difficult to check my Gmail account and I want a simpler way to check my inboxes without opening bulkier email clients.
email – Is there a tool that can automatically check my inbox and perform an action? – Personal Productivity Stack Exchange
Yeah I think so. However, it will take a lot of work. Are you meaning something like keyword matching? like natural language processing?
Εxcellent items from you, man. I’ve keep in mind your ѕtuff previous to ɑnd
you are simply too fantastic. І really like what yߋu Һave acquirеd here, really like whɑt you’гe stating and the way in whicɦ during which
you assert it. Yօu make it enjoyable and you still take care of to stay it smart.
I can’t wait to rеad far more from you. Ƭhis is
rеally a great websіte.
It’s appropriate time to make some plans for the long run and it is time to be happy.
I’ve learn this post and if I may I want to recommend you
few fascinating things or suggestions. Perhaps you can write subsequent articles regarding
this article. I desire to read even more issues about it!
When I initially left a comment I appear to have clicked
the -Notify me when new comments are added- checkbox and from now on every time a
comment is added I recieve four emails with the exact same comment.
Is there a way you can remove me from that service?
Thanks a lot!
I usually do not even learn how I ended up here, but
I thought this create was once good. I don’t recognize
who you could be but definitely you’re attending a famous blogger if you happen to aren’t already.
Cheers!
Very good post. Much obliged.