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.

  1. Sign up for a Mailazy account.
  2. Complete Domain Authentication.
  3. 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": ["[email protected]"],'
      '"from": "Sender <sender[email protected]>",'
      '"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"))