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 library helps you use the Postal API in Python 3.9 (and above) to send Emails, get Message Details & Deliveries and Implement Events to handle Server Webhooks.
It uses Requests the simple, yet elegant HTTP library to handle all the http sorcery.
PYostal is available on PyPI:
$ python -m pip install pyostal
PYostal officially supports Python 3.9+.
You will need an API Credential from your Postal Installation to use the API Client.
from pyostal.client import Client
# Create a new Postal client using the server key of your Postal Installation.
client = Client('https://postal.yourdomain.com', 'your-api-key')
# Optional: You can add any aditional Headers for your API installation
# (Maybe Authorization)
# You just add a dict with your headers:
headers = {
'Authorization' => 'Basic RTYtaO54BGBtcG9yYWwyMDIw'
}
client = Client('https://postal.yourdomain.com', 'your-api-key', headers)
#Or you can add them manually to a Client Instance:
client.headers = headers
Sending an email is simple. You can follow the example below:
# Create a dict with the message:
payload = {
'to': ['mail@example.com'],
'from_address': 'othermail@example.com',
'reply_to': 'reply-to@example.com',
'subject': 'This is a subject',
'plain_body': 'This is a body'
}
#send it using the client. that's it
response = client.send(payload)
Or Create a new Email instance and add manually each of the Mail attributes
from pyostal.emails import Email
email = Email({
'to': ['mail@example.com'],
'bcc': ['test1@example.com', 'test2@example.com],
'from_address': 'othermail@example.com',
'reply_to': 'reply-to@example.com',
'subject': 'This is a subject',
'plain_body': 'This is a body'
})
email.add_cc('emailcc@example.com')
email.html_body = "<p>This is a HTML body</p>"
# Here we get a pyostal.response.Response instance
response = client.send(Email)
You can get more information about the Postal API and Payloads in the Postal Project Wiki
Rafael Nevarez
FAQs
A Python lightweight Postal API Client
We found that pyostal 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.