News for hackers. Stuff that matters.
Re:Show HN: Python library to read and manage your Gmail by spindritf on Tuesday August 06, 2013 @06:10PM (#6169561)
You can also retrieve the password from your system keyring[1]

    import keyring

    pass_is = keyring.get_password('gmail', '[email protected]')
you set it with

    set_password(servicename, username, password)
so

    set_password('gmail', '[email protected]', 'one of those per app passwords if you use 2factor for example')
[1] https://pypi.python.org/pypi/keyring
Re:Show HN: Python library to read and manage your Gmail by grinich on Tuesday August 06, 2013 @11:17PM (#6170613)
Even better, use oauth2 tokens instead of your username/password.

Here's a script to generate them: https://google-mail-oauth2-tools.googlecode.com/svn/trunk/py...

Re:Show HN: Python library to read and manage your Gmail by codezero on Tuesday August 06, 2013 @07:51PM (#6169980)
That's amazing, I never knew this existed, thanks!
Re:Show HN: Python library to read and manage your Gmail by mcrittenden on Tuesday August 06, 2013 @07:31PM (#6169909)
This is great.

For the record, if you just need to do some simple scripting of your Gmail, maybe on cron, Google Apps Script is great for that. https://developers.google.com/apps-script/

Here's a recent simple example I wrote up. http://mikecr.it/ramblings/marking-gmail-read-with-apps-scri...

Re:Show HN: Python library to read and manage your Gmail by kbar13 on Tuesday August 06, 2013 @06:37PM (#6169672)
Cool!

If you're looking for non-gmail-specific email lib thingerator, check out IMAPClient (it's better than imaplib I swear!):

http://imapclient.readthedocs.org/en/latest/

Re:Show HN: Python library to read and manage your Gmail by ajaxaddicted on Wednesday August 07, 2013 @05:00AM (#6171629)
There is also Imbox https://github.com/martinrusev/imbox, which is a Python library for reading all kinds of IMAP mailboxes, not just Gmail
Re:Show HN: Python library to read and manage your Gmail by superchink on Wednesday August 07, 2013 @02:54AM (#6171260)
Slightly off topic, but does anyone know of a similar library for Google Calendar that's any good?
Re:Show HN: Python library to read and manage your Gmail by astrada on Wednesday August 07, 2013 @04:11AM (#6171483)
There is the official Google APIs Client Library for Python (https://developers.google.com/google-apps/calendar/downloads). You can even test the RESTful API online using the Google APIs Explorer (https://developers.google.com/apis-explorer/#p/calendar/v3/).
Re:Show HN: Python library to read and manage your Gmail by superchink on Wednesday August 07, 2013 @03:01PM (#6174885)
I knew about that. Maybe I just want a good example application to use as a reference…
Re:Show HN: Python library to read and manage your Gmail by eliasmacpherson on Wednesday August 07, 2013 @04:54AM (#6171614)
This is really cool. The only thing I use gmail web interface for since I moved to mutt and IMAP, is forwarding already sent emails with large attachments to new addresses. They way I have mutt set up is that it downloads the attachment first and then sends it once per recipient. The web interface just sends it, so I wonder is there a way to duplicate that functionality with mutt or with a library like this.
Re:Show HN: Python library to read and manage your Gmail by duvander on Wednesday August 07, 2013 @12:48AM (#6170902)
I really wish the username/password option wasn't supported. What use cases aren't possible with OAuth?
Re:Show HN: Python library to read and manage your Gmail by deepGem on Wednesday August 07, 2013 @02:39AM (#6171226)
Guess I can potentially use this as a module in a tornado/Django web application for scheduling email, without having the user to sign in to gmail explicitly or opening up a separate pop-up/browser window.
Re:Show HN: Python library to read and manage your Gmail by hatchoo on Wednesday August 07, 2013 @01:59AM (#6171139)
This is great. Thank you for sharing.

I've been planning to create a Python script to help me automatically label my older emails based on content. This is a big help.

Re:Show HN: Python library to read and manage your Gmail by ibudiallo on Tuesday August 06, 2013 @09:44PM (#6170329)
Thank you, this is really useful.

Just when I needed it and wanted to write one you posted it. I don't think I would have done half the good job you did.

Re:Show HN: Python library to read and manage your Gmail by charlierguo on Tuesday August 06, 2013 @10:30PM (#6170471)
Thanks! I was working on a side project that needed to access my GMail, and I couldn't believe that a good library didn't exist already. If you find any bugs or use cases that aren't covered well, file an issue or make a contribution!
Re:Show HN: Python library to read and manage your Gmail by arms on Tuesday August 06, 2013 @08:12PM (#6170061)
Thank you for sharing this. I've been very interested in building my own Gmail client the past few weeks, and this looks like a nice starting point.
Re:Show HN: Python library to read and manage your Gmail by AnSavvides on Wednesday August 07, 2013 @05:20AM (#6171692)
Very cool - I am sure a lot of people will get good use out of it. Rather surprised nothing like this already existed.
Re:Show HN: Python library to read and manage your Gmail by bussiere on Wednesday August 07, 2013 @06:00AM (#6171786)
how to get the attachment files ? i didn't see anyhting in the doc about it ... Are they in the body ?
Re:Show HN: Python library to read and manage your Gmail by knes on Tuesday August 06, 2013 @08:26PM (#6170109)
Didn't know the Ruby one existed, thanks for that!
Re:Show HN: Python library to read and manage your Gmail by txsl on Tuesday August 06, 2013 @09:20PM (#6170262)
My experience of the Ruby client referenced was that it was a little out of date. I was seeing errors when trying to use it a couple of weeks ago.
Re:Show HN: Python library to read and manage your Gmail by tejasbubane on Wednesday August 07, 2013 @05:51AM (#6171768)
I am using the Gmail gem (https://github.com/nu7hatch/gmail) in couple of my rails projects and it works perfect. Every single mail is delivered.
Re:Show HN: Python library to read and manage your Gmail by txsl on Friday August 09, 2013 @05:12AM (#6184520)
Ah, I was try to read emails and get Ruby to process them.
Re:Show HN: Python library to read and manage your Gmail by matt_ on Tuesday August 06, 2013 @11:11PM (#6170590)
there are two ruby gems for Gmail, which did you use?
Re:Show HN: Python library to read and manage your Gmail by txsl on Friday August 09, 2013 @05:11AM (#6184518)
I actually tried both, as I remember
Re:Show HN: Python library to read and manage your Gmail by maskedinvader on Tuesday August 06, 2013 @09:17PM (#6170252)
thank you for this. I was looking for something like this for a project I was working on
Re:Show HN: Python library to read and manage your Gmail by charlierguo on Tuesday August 06, 2013 @10:32PM (#6170474)
I built it because of a project I was working on :). Feel free to create an issue if you need some new features or have use cases that aren't covered.
Re:Show HN: Python library to read and manage your Gmail by kudu on Wednesday August 07, 2013 @12:06AM (#6170767)
This looks pretty nice. It's really too bad that it works with a Google service.
Re:Show HN: Python library to read and manage your Gmail by mkesper on Wednesday August 07, 2013 @07:23AM (#6172022)
Right, who still wants to share their data with Google?
Re:Show HN: Python library to read and manage your Gmail by giis on Wednesday August 07, 2013 @07:37AM (#6172088)
interesting,will try it.