Skip to main content

My Gmail API Wrapper

Project description

JT_Gmail

This is a simple interface for programmatically sending emails using the Gmail API.

pip install JT_Gmail

To get started you must create a project and enable the Gmail API, create OAuth2 credentials and download them in a json file.

Before you can use this module for the first time, you must run:

import JT_Gmail as gmail

gmail.GetToken(scopes=['scope1', 'scope2'], email_address='user@gmail.com', cred_path="path_to_your_credentials.json")

Supply the scopes you plan on using as *args. A list of all the scopes can be found here. Each function also includes the required scopes in its docstring.

This will prompt for authentication and generate the proper token to use the scopes you supplied. The token and credentials are saved for later use, so you might only have to run that line once. As you perform actions, if they need new permissions, they will be requested. Authentication will be required for each gmail user you wish to use.

To send emails, it's as easy as:

import JT_Gmail as gmail

with open("email.html") as file:
    gmail.SendHTMLEmail(
        sender='sender@gmail.com', 
        to="recipient@some.website", 
        subject="Example Email", 
        message_html=file.read()
)

This was base heavily on code snippets supplied by Google.

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

JT_Gmail-0.0.24.tar.gz (7.5 kB view hashes)

Uploaded Source

Built Distribution

JT_Gmail-0.0.24-py3-none-any.whl (9.3 kB view hashes)

Uploaded Python 3

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