{"id":13502629,"url":"https://github.com/charlierguo/gmail","last_synced_at":"2025-04-13T01:59:44.675Z","repository":{"id":50752202,"uuid":"11730622","full_name":"charlierguo/gmail","owner":"charlierguo","description":"A Pythonic interface for Google Mail","archived":false,"fork":false,"pushed_at":"2023-07-09T19:49:08.000Z","size":452,"stargazers_count":1784,"open_issues_count":60,"forks_count":389,"subscribers_count":89,"default_branch":"master","last_synced_at":"2025-04-06T00:04:31.679Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/charlierguo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2013-07-29T03:46:41.000Z","updated_at":"2025-04-02T08:10:33.000Z","dependencies_parsed_at":"2022-09-10T12:20:34.482Z","dependency_job_id":"83270226-fee0-4d5d-979a-9afa0f7f3b3a","html_url":"https://github.com/charlierguo/gmail","commit_stats":{"total_commits":56,"total_committers":14,"mean_commits":4.0,"dds":0.5178571428571428,"last_synced_commit":"4626823d3fbf159d242a50b33251576aeddbd9ad"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlierguo%2Fgmail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlierguo%2Fgmail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlierguo%2Fgmail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlierguo%2Fgmail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charlierguo","download_url":"https://codeload.github.com/charlierguo/gmail/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654046,"owners_count":21140235,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T22:02:20.352Z","updated_at":"2025-04-13T01:59:44.656Z","avatar_url":"https://github.com/charlierguo.png","language":"Python","readme":"# GMail for Python\n\nA Pythonic interface to Google's GMail, with all the tools you'll need. Search, \nread and send multipart emails, archive, mark as read/unread, delete emails, \nand manage labels.\n\n__This library is still under development, so please forgive some of the rough edges__\n\nHeavily inspired by [Kriss \"nu7hatch\" Kowalik's GMail for Ruby library](https://github.com/nu7hatch/gmail)\n\n## Author\n\n* [Charlie Guo](https://github.com/charlierguo)\n\n## Installation\n\nFor now, installation is manual (`pip` support not yet implemented) and the only requirement is to use Python 2 (2.7+ to be precise):\n\n    git clone git://github.com/charlierguo/gmail.git\n\n## Features\n\n* Search emails\n* Read emails \n* Emails: label, archive, delete, mark as read/unread/spam, star\n* Manage labels\n\n## Basic usage\n\nTo start, import the `gmail` library.\n\n    import gmail\n    \n### Authenticating gmail sessions\n\nTo easily get up and running:\n\n    import gmail \n\n    g = gmail.login(username, password)\n\nWhich will automatically log you into a GMail account. \nThis is actually a shortcut for creating a new Gmail object:\n    \n    from gmail import Gmail\n\n    g = Gmail()\n    g.login(username, password)\n    # play with your gmail...\n    g.logout()\n\nYou can also check if you are logged in at any time:\n\n    g = gmail.login(username, password)\n    g.logged_in # Should be True, AuthenticationError if login fails\n\n### OAuth authentication \n\nIf you have already received an [OAuth2 access token from Google](https://developers.google.com/accounts/docs/OAuth2) for a given user, you can easily log the user in. (Because OAuth 1.0 usage was deprecated in April 2012, this library does not currently support its usage)\n\n    gmail = gmail.authenticate(username, access_token)\n\n### Filtering emails\n    \nGet all messages in your inbox:\n\n    g.inbox().mail()\n\nGet messages that fit some criteria:\n\n    g.inbox().mail(after=datetime.date(2013, 6, 18), before=datetime.date(2013, 8, 3))\n    g.inbox().mail(on=datetime.date(2009, 1, 1)\n    g.inbox().mail(sender=\"myfriend@gmail.com\") # \"from\" is reserved, use \"fr\" or \"sender\"\n    g.inbox().mail(to=\"directlytome@gmail.com\")\n\nCombine flags and options:\n\n    g.inbox().mail(unread=True, sender=\"myboss@gmail.com\")\n    \nBrowsing labeled emails is similar to working with your inbox.\n\n    g.mailbox('Urgent').mail()\n    \nEvery message in a conversation/thread will come as a separate message.\n\n    g.inbox().mail(unread=True, before=datetime.date(2013, 8, 3) sender=\"myboss@gmail.com\")\n    \n### Working with emails\n\n__Important: calls to `mail()` will return a list of empty email messages (with unique IDs). To work with labels, headers, subjects, and bodies, call `fetch()` on an individual message. You can call mail with `prefetch=True`, which will fetch the bodies automatically.__\n\n    unread = g.inbox().mail(unread=True)\n    print unread[0].body\n    # None\n\n    unread[0].fetch()\n    print unread[0].body\n    # Dear ...,\n\nMark news past a certain date as read and archive it:\n\n    emails = g.inbox().mail(before=datetime.date(2013, 4, 18), sender=\"news@nbcnews.com\")\n    for email in emails:\n        email.read() # can also unread(), delete(), spam(), or star()\n        email.archive()\n\nDelete all emails from a certain person:\n\n    emails = g.inbox().mail(sender=\"junkmail@gmail.com\")\n    for email in emails:\n        email.delete()\n     \nYou can use also `label` method instead of `mailbox`: \n\n    g.label(\"Faxes\").mail()\n\nAdd a label to a message:\n\n    email.add_label(\"Faxes\")\n\nDownload message attachments:\n\n    for attachment in email.attachments:\n        print 'Saving attachment: ' + attachment.name\n        print 'Size: ' + str(attachment.size) + ' KB'\n        attachment.save('attachments/' + attachment.name)\n    \nThere is also few shortcuts to mark messages quickly:\n\n    email.read()\n    email.unread()\n    email.spam()\n    email.star()\n    email.unstar()\n\n### Roadmap\n* Write tests\n* Better label support\n* Moving between labels/mailboxes\n* Intuitive thread fetching \u0026 manipulation\n* Sending mail via Google's SMTP servers (for now, check out https://github.com/paulchakravarti/gmail-sender)\n\n## Copyright\n\n* Copyright (c) 2013 Charlie Guo\n\nSee LICENSE for details.\n\n","funding_links":[],"categories":["Third-party APIs","资源列表","Python","Awesome Python"],"sub_categories":["第三方 API","Third-party APIs"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharlierguo%2Fgmail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharlierguo%2Fgmail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharlierguo%2Fgmail/lists"}