04.30.06
gmail from the command prompt
So over the past few weeks I've been playing around with gmail and python... and libgmail.
I've decided that more people should be introduced to this and the functionality of it, so I've created a small program to allow people to play around with it... It should run on any version of python, however, I've written it with Python 2.4 in mind and of course you'll require libgmail from the above link.
My script, checkgmail.py, provides the following functionality:
---Cut from help---
Usage: ./checkgmail.py
Options:
-a All messages
-r Only read messages
-u Only unread messages
-h Display this help message
Parameters:
-L
-R Read the messages (display message content)
-S Return the subject lines
-C Display a message count
-Q Run the specified query (search)
-N Number of messages to return (default: ALL)
-U GMail username
-P GMail Password (default: prompt)
---End Help--- The idea is that you can pass 1 option and multiple parameters. By default it should, and I say should because I haven't extensively tested this software, prompt for a username and a password, log in and parse all unread mail in your inbox... however it won't display any information. Some examples you could use: To check and see if your mom has sent you any mail and to check the subjects you could use this command:
checkgmail.py -u -F mom@hotmail.com -S
To read the last message your girlfriend sent you, you could run something like this
checkgmail.py -u -F gf@hotmail.com -R -N 1
One important thing to remember is that whenever you parse unread messages, even if you don't display them... libgmail is still marking them read... don't let this confuse you when you revisit gmail through your browser.
Download checkgmail.py
Peace,
HT


teddyber said,
January 15, 2007 at 9:12 am
Hello!
this script is great however, the -N options doesn’t work for me. the loop never breaks…
teddyber said,
January 15, 2007 at 11:42 am
i fixed it with a int cast in the options parsing
Tyler Reguly said,
January 28, 2007 at 5:21 am
Sorry I never responded Teddyber… I always forget to pay attention to my own comments… I promise to resolve that in the future..
I’m sure the script has some issues… I threw it together rather quickly… just thought it was something cool
I’m glad you enjoy it.
Rajib Roychowdhury said,
April 26, 2007 at 2:13 pm
hay can u plz provide me the high level diagram or idea how u did it
it will help me a lot6