Skip to content

AMuriuki/gmail-api-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Using Gmail API with Python

This project uses Gmail API to send, search, delete and mark emails as read or unread.

Getting Started

  1. Clone repo & cd into directory
git clone https://github.com/AMuriuki/gmail-api-python.git
  1. Enable Gmail API

    You'll need a token to connect to Gmail's API. First head over to Google API's dashboard to enable the API.

    Use the search bar to search for Gmail API, click on it, then enable it. Create an OAuth 2.0 client ID, click on Create Credentials and choose OAuth Client ID.

    Select Desktop App as the Application type and proceed. Go ahead and download the json file with your client ID & Secret.

    Move the file to the root of your project directory, and rename it to credentials.json

  2. Create virtual env & activate it (Optional)

python3 -m venv venv

. venv/bin/activate
  1. Install required modules
pip install -r requirements.txt
  1. Edit env.example accordingly and rename to .env
email_address="youremail@gmail.com"

# add email recipients seperated by a comma
recipients="someemail@example.com, anotheremail@example.com"
  1. To send email:
python send_email.py "THIS IS THE SUBJECT" "And this is the body of this test email" --files attachment1.txt test.png

About

This project uses Gmail API with python to send, search, delete and mark emails as read or unread.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages