Skip to content

Send an email with Gmail and Python, use OAuth flow

Notifications You must be signed in to change notification settings

MichaelCurrin/send-mail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Send Mail

Send an email with Gmail and Python, use OAuth flow

Why OAuth?

Use the OAuth flow to sign into your Gmail account in the browser and then do requests using a token, so that your Gmail password does not have to be entered in a config file or stored somewhere on your machine.

Also, once you authenticate the first time, your credentials will be cached for future runs.

Instllation

  1. Make sure to follow the step to enable API for Gmail and download a JSON file.
  2. Clone the project.
  3. Install Python.
  4. Install dependencies in virtual environment.
    $ pip install requirements.txt

Usage

  1. Run the script.
    $ python -m sendmail
  2. Follow the auth flow.

Links

Based on Gmail dev docs tutorial:

See also tutorial which uses a less secure approach and requires you to allow less secure apps.

See other sample scripts for Google suite.

About

Send an email with Gmail and Python, use OAuth flow

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages