Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gmaily

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gmaily

Unofficial Gmail python client with pythonic API.

  • 0.0.3
  • PyPI
  • Socket score

Maintainers
1

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

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc