The Mailercloud Email API allows you to send emails automatically from your application or website. You can define the sender, recipients, subject, email content, and even add attachments. This is useful for sending automated emails like order confirmations, password resets, or marketing emails.
To use this API, you need an API key for authentication.
POST https://email-api.mailercloud.com/email
Content-Type: application/json
Authorization: YOUR_API_KEY
{
"email": {
"from": "from@example.com",
"fromName": "John Doe",
"replyTo": [
"replyone@example.com",
"replytwo@example.com"
],
"subject": "email subject",
"text": "text body",
"html": "html body",
"amp_html" : "amp_body",
"recipients": {
"to": [{
"name": "Recipient1",
"email": "abc12345"
}, {
"name": "Recipient2",
"email": "abc@example.com"
}],
"cc": [
"recipient_cc1@example.com",
"recipient_cc2@example.com"
],
"bcc": [
"recipient_bcc1@example.com",
"recipient_bcc2@example.com"
]
},
"attachments": [{
"name": "Attachment1",
"url": "https://link/to/attachment/1"
},{
"name": "Attachment2",
"url": "http://link/to/attachment/2"
}]
},
"metadata": {
"campaignType": "PROMOTIONAL",
"timestamp": "2018-01-25T10:24:16+0000",
"messageId": "your-message-id",
"custom" : {
"key1" : "val1",
"key2" : "val2"
}
},
"version": "1.0"
}
Parameter | Type | Description |
email.from | String | Sender’s email address |
email.fromName | String | Sender’s name |
email.replyTo | Array | Reply-to email addresses |
email.subject | String | Email subject |
email.text | String | Plain text version of the email |
email.html | String | HTML version of the email |
email.recipients | Object | Contains recipient information (To, CC, BCC) |
email.attachments | Array | Attach files to your email |
When the email is sent successfully, the API returns:
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "SUCCESS",
"statusCode": 1000,
"message": "NA"
}
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "ERROR",
"statusCode": 9002,
"message": "Daily email sending quota is over."
}
HTTP/1.1 400 Bad Request
Content-Type: application/json
{
"status": "ERROR",
"statusCode": 9022,
"message": "Unsupported version",
"supportedVersion": "1.0"
}
Status Code | Meaning |
1000 | Success |
9001 | Throttling error |
9002 | Message sending quota exceeded |
9003 | Authentication failure |
9004 | Recipient address not specified |
9005 | From field missing |
9006 | Soft bounce (temporarily deferred) |
9007 | Hard bounce |
9008 | Email reported as spam |
9009 | Email unsubscribed |
9010 | Email in suppression list |
9011 | Sender address not verified |
9012 | ESP rejected message |
9013 | Request to ESP expired |
9014 | ESP unavailable |
9015 | IP not whitelisted with ESP |
9016 | Subject field empty |
9017 | Invalid sender address |
9018 | Invalid email address |
9019 | Recipient's mailbox is full |
9020 | Error processing email at Private ESP |
9021 | Mailbox was not found on email server |
9022 | Unsupported or unknown version |
9024 | Authorization failure |
9452 | Message overloading |
9512 | Host email server not found |
9999 | Unknown error occurred |