/smtp2go-python

Python library for interacting with the smtp2go API

Primary LanguagePythonMIT LicenseMIT

Build Status Coverage Status PyPI version Dependency Status Code Climate Issue Count license

smtp2go

Python library to facilitate interations with smtp2go API

Installation

Add this line to your application's requirements.txt:

smtp2go

Or install it yourself with pip:

$ pip install smtp2go

Looking to integrate with Django? Try our Django library

Usage

Sign up for a free account here and get an API key. At your shell, run:

$ export SMTP2GO_API_KEY="<your_API_key>"

Here is a REPL session demonstrating sending an email and viewing the response:

In [1]: from smtp2go.core import Smtp2goClient

In [2]: client = Smtp2goClient()

In [3]: payload = {
   ...: 'sender': 'dave@example.com',
   ...: 'recipients': ['matt@example.com'],
   ...: 'subject': 'Trying out Smtp2go!',
   ...: 'text': 'Test Message',
   ...: 'html': '<html><body><h1>Test HTML message</h1></body><html>',
   ...: 'custom_headers': {'Your-Custom-Headers': 'Custom Values'}}

In [4]: response = client.send(**payload)

In [5]: response.success
Out[5]: True

In [6]: response.json
Out[6]:
{'data': {'failed': 0, 'failures': [], 'succeeded': 1},
 'request_id': '<redacted>'}

In [7]: response.errors
Out[7]: []

In [8]: response.rate_limit
Out[8]: rate_limit(remaining=250, limit=250, reset=16)

Full API documentation can be found here

Changelog

  • Version 2.0.0:
    • Added HTML email functionality
  • Version 1.2.0:
    • Added custom header sending functionality
  • Version 1.0.1:
    • Added ratelimiting attributes to response
  • Version 1.0.0:
    • Out of alpha

Development

Clone repo and install requirements into a virtualenv. Run tests with pytest.

Contributing

Bug reports and pull requests are welcome on GitHub here

License

The package is available as open source under the terms of the MIT License.