Python SDK for Paubox Email REST API
Project description
Paubox Package
This package and Paubox Transactional Email HTTP API are currently in alpha development.
This is the official Python package for the Paubox Transactional Email HTTP API. The Paubox Transactional Email API allows your application to send secure, HIPAA-compliant email via Paubox and track deliveries and opens.
Installation
Getting Paubox API Credentials
You will need to have a Paubox account. Please contact Paubox Customer Success for details on gaining access to the Transactional Email API alpha testing program.
Setup Environment Variables
$ echo "export PAUBOX_API_KEY='YOUR_API_KEY'" > .env
$ echo "export PAUBOX_HOST='https://api.paubox.net/v1/YOUR_ENDPOINT_NAME'" >> .env
$ echo ".env" >> .gitignore
$ source .env
Install Package
$ pip install paubox
Dependencies
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
paubox_client = paubox.PauboxApiClient()
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
paubox_client = paubox.PauboxApiClient()
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)
Sending Messages with all available headers
Using Mail Class Helper
import paubox
import base64
from paubox.helpers.mail import Mail
paubox_client = paubox.PauboxApiClient()
recipients = ["recipient@example.com"]
from_ = "sender@yourdomain.com"
subject = "Testing!"
attachment_content = base64.b64encode("Hello World!")
content = {
"text/plain": "Hello World!",
"text/html": "<html><body><h1>Hello World!</h1></body></html>"
}
optional_headers = {
"attachments": [{
"fileName": "the_file.txt",
"contentType": "text/plain",
"content": attachment_content
}],
'reply_to': 'replies@yourdomain.com',
'bcc': 'recipient2@example.com'
}
mail = Mail(from_, subject, recipients, content, optional_headers)
response = paubox_client.send(mail.get())
print(response.status_code)
print(response.headers)
print(response.text)
Without the Mail Class Helper
import paubox
import base64
paubox_client = paubox.PauboxApiClient()
attachment_content = base64.b64encode("Hello World!")
mail = {
"data": {
"message": {
"recipients": [
"recipient@example.com"
],
"bcc": ["recipient2@example.com"],
"headers": {
"subject": "Testing!",
"from": "Sender <sender@yourdomain.com>",
"reply-to": "Reply-to <replies@yourdomain.com>"
},
"content": {
"text/plain": "Hello World!",
"text/html": "<html><body><h1>Hello World!</h1></body></html>"
},
"attachments": [{
"fileName": "the_file.txt",
"contentType": "text/plain",
"content": attachment_content
}]
}
}
}
response = paubox_client.send(mail)
print(response.status_code)
print(response.headers)
print(response.text)
Checking Email Dispositions
The SOURCE_TRACKING_ID of a message is returned in the response.text of your send request. Use response.to_dict to access the response text as a dictionary.
import paubox
paubox_client = paubox.PauboxApiClient()
disposition_response = paubox_client.get("SOURCE_TRACKING_ID")
print(disposition_response.status_code)
print(disposition_response.headers)
print(disposition_response.text)
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/Paubox/paubox-python.
License
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright
Copyright © 2018, Paubox Inc.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file paubox-python-0.0.2.tar.gz
.
File metadata
- Download URL: paubox-python-0.0.2.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31f1fb7730a71a2d9a5d1a16551ee5e751647f5077b32dada413792178ece039 |
|
MD5 | a52e1deee91cdad55faa3cea96f68372 |
|
BLAKE2b-256 | ea3793e77c2e4761436aeac9f987b4eda1ea10be3876a8b0d25f8ba22eaaaa32 |
File details
Details for the file paubox_python-0.0.2-py2-none-any.whl
.
File metadata
- Download URL: paubox_python-0.0.2-py2-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b6b37549cab1e9b8c6fc9c5967b16024040ab3ce21c1f97db5f2a43654bc311 |
|
MD5 | e75bb6c2c9e96c8aa058ef8395c2eb85 |
|
BLAKE2b-256 | 669e0bdc479b61281811937b9194b0d673735e1903cbd6772e38134b4d4f5a1c |