Skip to main content

Send mail from gmail using python

Project description


This is a very simple package that enables you to send mail through gmail using python. It’s not a big deal, it does not read your emails, no calendars, no drafts… It does just one thing, sending emails.


  • Python 3
  • pip3 for installation


I recommend using the github repository, it’s more up-to-date.


git clone
cd pygmail
python3 install

You can copy the script to a folder in your $PATH, for example:

sudo cp bin/ /usr/local/bin/

Using pip:

pip3 install --upgrade git+

As far as I know pip will not take care of the script files in bin/.


It uses smtp, that’s all. You can always check the source code, of course


From a interactive python shell or from any python file:

from pygmail2.Pygmail import Pygmail
Pygmail().send_mail('', 'hi, there', '<b>important stuff </b>')

Using the in shell -h
usage: A python script for sending emails from commandline using gmail
       [-h] [--subj SUBJ] [--body_file BODY_FILE] to_addr

positional arguments:
  to_addr               Recepient email address

optional arguments:
  -h, --help            show this help message and exit
  --subj SUBJ, -s SUBJ  Subject of the email
  --body_file BODY_FILE, -b BODY_FILE
  • Write up your mail body in the shell in a interactive fashion: -s hi_there

  • Pipe your mail body to the script:

    echo “hi, how are you?” | -s hi_there

  • Load the mail body with a html file:

    wget -O body.html -s hi_there -b body.html

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

pygmail2-0.2.tar.gz (1.9 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page