Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Readme
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.
You will need to have a Paubox account. You can sign up here.
Once you have an account, follow the instructions on the Rest API dashboard to verify domain ownership and generate API credentials.
$ 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
$ pip install paubox-python
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)
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)
If you want to send non-PHI mail that does not need to be HIPAA-compliant, you can allow the message delivery to take place even if a TLS connection is unavailable.
This means the message will not be converted into a secure portal message when a nonTLS connection is encountered. For this, just pass allowNonTLS as True, as shown below:
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!"
}
optional_headers = {
'reply_to': 'replies@yourdomain.com',
'allowNonTLS': True
}
mail = Mail(from_, subject, recipients, content, optional_headers)
response = paubox_client.send(mail.get())
print(response.status_code)
print(response.headers)
print(response.text)
import paubox
paubox_client = paubox.PauboxApiClient()
mail = {
"data": {
"message": {
"recipients": [
"recipient@example.com"
],
'allowNonTLS': True,
"headers": {
"subject": "Testing!",
"from": "Sender <sender@yourdomain.com>",
"reply-to": "Reply-to <replies@yourdomain.com>"
},
"content": {
"text/plain": "Hello World!",
}
}
}
}
response = paubox_client.send(mail)
print(response.status_code)
print(response.headers)
print(response.text)
Paubox Secure Notifications allow an extra layer of security, especially when coupled with an organization's requirement for message recipients to use 2-factor authentication to read messages (this setting is available to org administrators in the Paubox Admin Panel).
Instead of receiving an email with the message contents, the recipient will receive a notification email that they have a new message in Paubox.
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!"
}
optional_headers = {
'reply_to': 'replies@yourdomain.com',
'forceSecureNotification': 'true'
}
mail = Mail(from_, subject, recipients, content, optional_headers)
response = paubox_client.send(mail.get())
print(response.status_code)
print(response.headers)
print(response.text)
import paubox
paubox_client = paubox.PauboxApiClient()
mail = {
"data": {
"message": {
"recipients": [
"recipient@example.com"
],
'forceSecureNotification': 'true',
"headers": {
"subject": "Testing!",
"from": "Sender <sender@yourdomain.com>",
"reply-to": "Reply-to <replies@yourdomain.com>"
},
"content": {
"text/plain": "Hello World!"
}
}
}
}
response = paubox_client.send(mail)
print(response.status_code)
print(response.headers)
print(response.text)
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',
'cc':['recipientcc@example.com'],
'forceSecureNotification': 'true',
'allowNonTLS': True
}
mail = Mail(from_, subject, recipients, content, optional_headers)
response = paubox_client.send(mail.get())
print(response.status_code)
print(response.headers)
print(response.text)
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"],
'cc':['recipientcc@example.com'],
'forceSecureNotification':'true',
'allowNonTLS': True,
"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)
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)
Bug reports and pull requests are welcome on GitHub at https://github.com/Paubox/paubox-python.
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 © 2019, Paubox Inc.
FAQs
Python SDK for Paubox Email REST API
We found that paubox-python demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.