Skip to the main content.
Talk to sales Start for free
Talk to sales Start for free

1 min read

Python 3 SDK added to Paubox Email API

Python 3 SDK added to Paubox Email API

This month we released SDK support for Python 3 for Paubox Email API. It should be noted we created a new project repo for Python 3. Our Python 2 SDK is still available. As a recap, Paubox Email API allows developers to programmatically send HIPAA compliant email and track delivery status. Paubox Email API is HITRUST CSF certified. By adding client library support for languages like Python, programmers can integrate and deliver secure email within minutes via our REST API. Let's dive into a quick example.

 

Installation

 

Getting Paubox API Credentials

 

You will need to have a Paubox account. You can  sign up for free here. Once you have an account, follow the instructions on the Paubox Email API dashboard to verify domain ownership and generate API credentials.

See Also: Paubox Email API Quickstart Guide

 

Configuring API Credentials

 

Include your API credentials in a config file (e.g. config.cfg)
PAUBOX_HOST: 'https://api.paubox.net/v1/YOUR_ENDPOINT_NAME'
PAUBOX_API_KEY: 'YOUR_API_KEY'
Next install config package using pip to load API credentials from config.cfg file:
$ pip3 install config

Install Package

$ pip3 install paubox-python3

Usage

 

Sending Messages with the Paubox Mail Helper

 

Sending via Paubox is easy. This is the minimum content needed to send an email.
import paubox
from paubox.helpers.mail import Mail

from config import Config 
with open("config.cfg") as config_file:
    paubox_config = Config(config_file)

paubox_client = paubox.PauboxApiClient(paubox_config.PAUBOX_API_KEY, paubox_config.PAUBOX_HOST)
recipients = ["recipient@example.com"]
from_ = "sender@yourdomain.com"
subject = "Testing!"
content = {"text/plain": "Hello World!"}
mail = Mail(from_, subject, recipients, content)
response = paubox_client.send(mail.get())
print(response.status_code)
print(response.headers)
print(response.text)

Sending Messages without the Mail Helper Class

import paubox

from config import Config 
with open("config.cfg") as config_file:
    paubox_config = Config(config_file)

paubox_client = paubox.PauboxApiClient(paubox_config.PAUBOX_API_KEY, paubox_config.PAUBOX_HOST)
mail = {
    "data": {
        "message": {
            "recipients": [
                "recipient@example.com"
            ],
            "headers": {
                "subject": "Testing!",
                "from": "sender@yourdomain.com"
            },
            "content": {
                "text/plain": "Hello World!",
            }
        }
    }
}
response = paubox_client.send(mail)
print(response.status_code)
print(response.headers)
print(response.text)
Try the Paubox Email API for Free

Subscribe to Paubox Weekly

Every Friday we'll bring you the most important news from Paubox. Our aim is to make you smarter, faster.