Email API Integration Guide with Python
Minimum code that you need to integrate Mailazy with your Python application
Prerequisites
You need to complete these given prerequisites, you can skip the step if you have already completed.
- Sign up for a Mailazy account.
- Complete Domain Authentication.
- Generate the Mailazy Access Key
Integrate Mailazy with Python
Start Sending mail using the code provided below:
import http.client
import mimetypes
conn = http.client.HTTPSConnection("api.mailazy.com")
payload = ('{'
'"to": ["example@example.com"],'
'"from": "Sender <sender@example.com>",'
'"subject": "<Subject>",'
'"content": [{"type": "text/plain","value": "<Content>"}]'
'}')
headers = {
'X-Api-Key': '<API KEY>',
'X-Api-Secret': '<API SECRET>',
'Content-Type': 'application/json'
}
conn.request("POST", "/v1/mail/send", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))