Python library to facilitate interactions with smtp2go API
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
Sign up for a free account here and get an API key. At your shell, run:
$ export SMTP2GO_API_KEY="<your_API_key>"
Or alternatively, pass your API key to the Smtp2goClient initialiser:
smtp2go_client = Smtp2goClient(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
- Version 2.3.1:
- Fixed the default value of custom headers.
- Version 2.3.0:
- Fixed the adding of custom headers to emails.
- Version 2.2.0:
- Adding the ability to send using templates.
- Version 2.1.0:
- Allowed API key to be passed to
Smtp2goClient
's initialiser. - Added pipenv.
- Allowed API key to be passed to
- 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
Clone repo and install requirements.txt
into a virtualenv. Run tests with pytest
.
Also we've included pipenv, so you can just cd
into the directory and pipenv shell
Bug reports and pull requests are welcome on GitHub here
The package is available as open source under the terms of the MIT License.