All Projects → SparkPost → Python Sparkpost

SparkPost / Python Sparkpost

Licence: other
SparkPost client library for Python

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Python Sparkpost

Django Anymail
Django email backends and webhooks for Amazon SES, Mailgun, Mailjet, Postmark, SendGrid, Sendinblue, SparkPost and more
Stars: ✭ 1,109 (+1174.71%)
Mutual labels:  django, email
Django mail admin
The one and only django app to receive & send mail with templates and multiple configurations.
Stars: ✭ 140 (+60.92%)
Mutual labels:  django, email
Django Notifs
Modular Notifications (InApp, Email, SMS, CustomBackend etc) for Django
Stars: ✭ 105 (+20.69%)
Mutual labels:  django, email
Modoboa
Mail hosting made simple
Stars: ✭ 1,998 (+2196.55%)
Mutual labels:  django, email
Django Email Confirm La
Django email confirmation for any model and any field
Stars: ✭ 23 (-73.56%)
Mutual labels:  django, email
Django Herald
A Django messaging library
Stars: ✭ 159 (+82.76%)
Mutual labels:  django, email
Django Mail Templated
Send emails using Django template system
Stars: ✭ 146 (+67.82%)
Mutual labels:  django, email
Hawkpost
Generate links that users can use to submit messages encrypted with your public key.
Stars: ✭ 843 (+868.97%)
Mutual labels:  django, email
Django Amazon Ses
A Django email backend that uses Boto3 to interact with Amazon Simple Email Service (SES).
Stars: ✭ 77 (-11.49%)
Mutual labels:  django, email
Django Rules
Awesome Django authorization, without the database
Stars: ✭ 1,255 (+1342.53%)
Mutual labels:  django
Django Rest Swagger Docs
Beginners approach to Django Rest Swagger
Stars: ✭ 86 (-1.15%)
Mutual labels:  django
Django Fakery
🏭 An easy-to-use implementation of Creation Methods for Django, backed by Faker.
Stars: ✭ 84 (-3.45%)
Mutual labels:  django
Wagtail Torchbox
Wagtail build of Torchbox.com
Stars: ✭ 84 (-3.45%)
Mutual labels:  django
Jaromail
A commandline tool to easily and privately handle your e-mail
Stars: ✭ 86 (-1.15%)
Mutual labels:  email
Mezzanine Api
RESTful web API for Mezzanine CMS
Stars: ✭ 84 (-3.45%)
Mutual labels:  django
Shynet
Modern, privacy-friendly, and detailed web analytics that works without cookies or JS.
Stars: ✭ 1,273 (+1363.22%)
Mutual labels:  django
Embedding Reference Apps
Reference applications for common web frameworks showing how to embed Metabase charts
Stars: ✭ 83 (-4.6%)
Mutual labels:  django
Drf Datatable Example Server Side
DataTables Example (server-side) - Python Django REST framework
Stars: ✭ 84 (-3.45%)
Mutual labels:  django
Django Admin Relation Links
An easy way to add links to relations in the Django Admin site.
Stars: ✭ 87 (+0%)
Mutual labels:  django
Pybooks
python books
Stars: ✭ 87 (+0%)
Mutual labels:  django

.. image:: https://www.sparkpost.com/sites/default/files/attachments/SparkPost_Logo_2-Color_Gray-Orange_RGB.svg :target: https://www.sparkpost.com :width: 200px

Sign up_ for a SparkPost account and visit our Developer Hub_ for even more content.

.. _Sign up: https://app.sparkpost.com/join?plan=free-0817?src=Social%20Media&sfdcid=70160000000pqBb&pc=GitHubSignUp&utm_source=github&utm_medium=social-media&utm_campaign=github&utm_content=sign-up .. _Developer Hub: https://developers.sparkpost.com

SparkPost Python API client

.. image:: https://travis-ci.org/SparkPost/python-sparkpost.svg?branch=master :target: https://travis-ci.org/SparkPost/python-sparkpost :alt: Build Status

.. image:: https://readthedocs.org/projects/python-sparkpost/badge/?version=latest :target: https://python-sparkpost.readthedocs.io/en/latest/ :alt: Documentation Status

.. image:: https://coveralls.io/repos/SparkPost/python-sparkpost/badge.svg?branch=master&service=github :target: https://coveralls.io/github/SparkPost/python-sparkpost?branch=master :alt: Coverage Status

The official Python package for using the SparkPost API.

Documentation

  • Documentation for python-sparkpost_
  • SparkPost API Reference_

.. _python-sparkpost: https://python-sparkpost.readthedocs.io/ .. _SparkPost API Reference: https://www.sparkpost.com/api

Installation

Install from PyPI using pip_:

.. code-block:: bash

$ pip install sparkpost

.. _pip: http://www.pip-installer.org/en/latest/

.. _pip: http://www.pip-installer.org/en/latest/

Python 2.7 or later is required.

Get a key

Go to API & SMTP_ in the SparkPost app and create an API key. We recommend using the SPARKPOST_API_KEY environment variable:

.. code-block:: python

from sparkpost import SparkPost
sp = SparkPost() # uses environment variable

Alternatively, you can pass the API key to the SparkPost class:

.. code-block:: python

from sparkpost import SparkPost
sp = SparkPost('YOUR API KEY')

For SparkPost EU and Enterprise accounts, pass in a second parameter to set the API host.

.. code-block:: python

from sparkpost import SparkPost
sp = SparkPost('YOUR API KEY', 'https://api.eu.sparkpost.com')

.. _API & SMTP: https://app.sparkpost.com/#/configuration/credentials

Send a message

Here at SparkPost, our messages are known as transmissions. Let's use the underlying transmissions API_ to send a friendly test message:

.. code-block:: python

from sparkpost import SparkPost

sp = SparkPost()

response = sp.transmissions.send(
    use_sandbox=True,
    recipients=['[email protected]'],
    html='<p>Hello world</p>',
    from_email='[email protected]',
    subject='Hello from python-sparkpost'
)

print(response)
# outputs {u'total_accepted_recipients': 1, u'id': u'47960765679942446', u'total_rejected_recipients': 0}

.. _transmissions API: https://www.sparkpost.com/api#/reference/transmissions

Django Integration

The SparkPost python library comes with an email backend for Django. Put the following configuration in settings.py file.

.. code-block:: python

SPARKPOST_API_KEY = 'API_KEY'
SPARKPOST_BASE_URI = 'api.sparkpost.com'
EMAIL_BACKEND = 'sparkpost.django.email_backend.SparkPostEmailBackend'

Replace API_KEY with an actual API key that you've generated in Get a Key_ section. Check out the full documentation_ on the Django email backend.

If you are using an EU account, set SPARKPOST_BASE_URI to api.eu.sparkpost.com. The default value is api.sparkpost.com.

.. _full documentation: https://python-sparkpost.readthedocs.io/en/latest/django/backend.html

Using with Google Cloud

There are a few simple modifications necessary to enable the use of the underlying requests library that python-sparkpost uses. First, add the requests and requests-toolbelt to your project's requirements.txt:

.. code-block::

requests
requests-toolbelt

Then create or update your appengine_config.py file to include the following:

.. code-block:: python

import requests
import requests_toolbelt.adapters.appengine

requests_toolbelt.adapters.appengine.monkeypatch()

Then deploy your app and you should be able to send using python-sparkpost on Google Cloud.

Contribute

#. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug. #. Fork the repository_ on GitHub and make your changes in a branch on your fork #. Write a test which shows that the bug was fixed or that the feature works as expected. #. Send a pull request. Make sure to add yourself to AUTHORS_.

.. _the repository: http://github.com/SparkPost/python-sparkpost .. _AUTHORS: https://github.com/SparkPost/python-sparkpost/blob/master/AUTHORS.rst

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].