Skip to main content

Unofficial Gmail python client with pythonic API.

Project description

gmaily

Unofficial Gmail python client with pythonic API.

Features

  • Clean API
  • No other dependencies than standard library
  • Lazy loading for content

Example

import sys
import getpass
import datetime

from gmaily import Gmaily

g = Gmaily()

user_email = input("Email: ")
user_pw = getpass.getpass()

if not g.login(user_email, user_pw):
    print("Cannot login")
    sys.exit(1)

msgs = g.inbox().after(datetime.date.today() - datetime.timedelta(weeks=2))
for msg in msgs.all():
    print("\n" + (" Mail UID: %d " % msg.uid).center(80, "=") + "\n")
    print("Subject:", msg.subject)
    print("From:", msg.sender)
    print("Date:", msg.date)
    print("Attachments:", msg.attachments)

    print("-" * 10)
    print(msg.text)

g.logout()

Usage

Searching Mailbox

SearchQuery, which is returned by some methods like Gmaily.inbox supports method chaining and you can easily mix search criterias together:

two_weeks_ago = datetime.date.today() - datetime.timedelta(weeks=2)
msgs = g.inbox().by("john@example.com").before(two_weeks_ago)

Alternatively, you can use other mailboxes than INBOX in the above example using Gmaily.mailbox method:

msgs = g.mailbox("URGENT").on(datetime.date.today())

You can then execute the query and fetch the results using SearchQuery.all:

print(msgs.all())

You can find the full list of supported criterias and their description at here. Note that ALL criteria is not present because it's the default criteria and SearchQuery.all stands for executing the query. Any other names like .fetch(), .do() could be taken the place, but I chose the .all() because famous ORMs use it too.

Some other criterias are omitted too:

  • NOT
  • OR
  • UID

Installation

It requires Python>=3.5.

$ pip3 install -U gmaily

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gmaily-0.0.3.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

gmaily-0.0.3-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file gmaily-0.0.3.tar.gz.

File metadata

  • Download URL: gmaily-0.0.3.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.8

File hashes

Hashes for gmaily-0.0.3.tar.gz
Algorithm Hash digest
SHA256 b20d43de0bf60cdb1896c288061994c24bf4ed0193be38d9f30134415265d74d
MD5 1baaa2b05d846ce996afbce6d6c8cf58
BLAKE2b-256 ee4e8995a44b268266a47e5e37b75aca9671eea1d835fdb294b9fc3da4b89507

See more details on using hashes here.

File details

Details for the file gmaily-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: gmaily-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.8

File hashes

Hashes for gmaily-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f8c9eea9015732c2a2aea775b511d059c912a56db612e20f61adbcce1331adda
MD5 1b16ceac1fb1185c108a7c12043c88c9
BLAKE2b-256 f23ab6a2890fe00987d840d95f7091886ce5086d10dc9c54c4e4f572f2df9acb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page