Email API
The endpoint allows you to start sending emails through Mailazy Email API.
Send Email
Sends email via the REST API interface. Pass the components of the messages such as To
, From
, Subject
as JSON payload.
Endpoint:
https://api.mailazy.com/v1/mail/send
JSON Payload:
Field | Description | Type | Sample Value |
---|---|---|---|
to | Email address of the recipient(s) | Array<String> | ["john@example.com"] |
from | Email address of the sender | String | "Sender <sender@domain.com>" |
reply_to | Reply to address | String | "Sender <sender@domain.com>" |
subject | Email subject | String | "Hello, World!" |
content | Email content | Array<Object> | [{"type": "text/plain", "value": "<Content>"},{"type": "text/html", "value": "<Content>"}] |
attachments | Email Attachments | Array<Object> | [{"type": "application/pdf", "file_name": "invoice.pdf", "content": "<base64-encoded-file>"}] |
Examples:
Send Email with HTML and Text Content
curl --location --request POST 'https://api.mailazy.com/v1/mail/send' \
--header 'X-Api-Key: <API KEY>' \
--header 'X-Api-Secret: <API SECRET>' \
--header 'Content-Type: application/json' \
--data-raw '{
"to" : ["john@example.com"],
"from": "Sender <sender@example.com>",
"subject": "Hello, World!",
"content": [{
"type": "text/plain",
"value": "Hey! ....."
},{
"type": "text/html",
"value": "Hey! ....."
}]
}'
Send Email with HTML and Text Content and Attachments
To send multiple attachments, it can be passed as an array of attachment objects encode as a base64 string.
curl --location --request POST 'https://api.mailazy.com/v1/mail/send' \
--header 'X-Api-Key: <API KEY>' \
--header 'X-Api-Secret: <API SECRET>' \
--header 'Content-Type: application/json' \
--data-raw '{
"to" : ["john@example.com"],
"from": "Sender <sender@example.com>",
"subject": "Hello, World!",
"content": [{
"type": "text/plain",
"value": "Hey! ....."
},{
"type": "text/html",
"value": "Hey! ....."
}],
"attachments": [{
"type": "application/pdf",
"file_name": "example.pdf",
"content": "<base64-encoded-file>"
}]
}'