Skip to main content

Simple library to send email using GMail (includes background worker and logging classes) [Python 2/3 support]

Project description

gmail
-----

The 'gmail' module provides a simple wrapper around the smtplib/email
modules to provide an easy programmatic interface for sending email using
the GMail SMTP service.

The module provides the following classes:

GMail - Basic interface to GMail SMTP service
GMailWorker - Background worker to send messages asynchronously
(uses multiprocessing module)
GMailHandler - GMail handler for logging framework
Message - Wrapper around email.Message class simplifying
creation of email message objects

The module also provides a cli interface to send email if run directly
(python -mgmail.cli)

Basic usage:

>>> gmail = GMail('A.User <user@gmail.com>','password')
>>> msg = Message('Test Message',to='xyz <xyz@xyz.com>',text='Hello')
>>> gmail.send(msg)

The Message class also provides support to simply generate html email and
add attachments.

>>> msg = Message('Test Message',to='xyz@xyz.com',text="Hello",html="<b>Hello</b>",attachments=['img.jpg'])

In Python3 messages will be unicode (utf8) encoded by default unless the text is
passed a a bytes object (the inverse is true in Python 2)

(Note: you should generate an app password rather than using your account password
https://security.google.com/settings/security/apppasswords)

For examples of use see cli.py and test_gmail.py/test_message.py

Changelog:

* 0.1 2012-10-17 Initial Release
* 0.2 2012-10-18 Restructure module
* 0.3 2012-12-28 Fix logging/worker
* 0.3.1 2012-12-28 CLI attachment mime-type fix
* 0.4 2013-08-24 Allow user to specify 'From' and 'Reply-To' header by passing 'sender'
(Pull from from https://github.com/Kami - thanks)
* 0.5 2014-02-12 Move _gmail_worker to module function to fix
multiprocessor problem on win32
(Fix from gabriel.nevarez@gmail.com - thanks)
* 0.6 2016-09-25 Python 3 support

License:

* BSD

Author:

* Paul Chakravarti (paul.chakravarti@gmail.com)

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

gmail-0.6.1.tar.gz (7.9 kB view details)

Uploaded Source

File details

Details for the file gmail-0.6.1.tar.gz.

File metadata

  • Download URL: gmail-0.6.1.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for gmail-0.6.1.tar.gz
Algorithm Hash digest
SHA256 77e68986fe1360de176a9517de4f18a4dc39abb4c596ebb355474d4fb537d792
MD5 018a5b54da11dead807351aad3ef8607
BLAKE2b-256 e03ae6bc251a32c9751cfad972757363b3c78c5b82622c8cea8e81271ba60c0c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page