Skip to main content

MailerSend

Profile Requirements

To deliver a message to a recipient over MailerSend, Courier must be provided the recipient's email address. This value should be included in the recipient profile as email.

JSON
{
"message": {
// Recipient Profile
"to": {
"email": "example@example.com"
}

// ... rest of message definition
}
}

Authentication Token Generation

First you need to add your domain and verify it.

Click on “Manage” button and in the following screen generate an authentication token

Override

Overrides can be used to change the request body that Courier uses to send an email. Overrides are useful when a field is not yet supported by Courier or you would like to override the value that Courier generates. You can override any of the fields supported by MailerSend's https://api.mailersend.com/v1/email endpoint (see all mail send request body fields here. Below is an example of overriding the subject:

JSON
{
"message": {
"template": "<COURIER_NOTIFICATION_ID>",
"profile": {
"email": "hello@courier.com"
},
"data": {
"name": "Abdul Ahmady"
},
"providers": {
"mailersend": {
"override": {
"config": {
"apiKey": "<YOUR_OVERRIDDEN_API_KEY>",
"fromAddress": "<YOUR_OVERRIDDEN_From_ADDRESS>",
"url": "<YOUR_OVERRIDDEN_URL>"
}
}
}
}
}
}

MailerSend 422 Response Code

When submitting an API request to MailerSend, you will get a numbered response code. One of the most common response error codes is a 422 error. This could be due to a couple of reasons:

From email must be verified

The domain of the from email address must match the domain that the API token or SMTP credentials are from.

You must provide HTML and/or text versions of the email or template ID.

The API request is missing one of the 3 parameters needed to send the content, either the text or HTML version or the template ID.

This file type is not supported.

The attachment file encoded in Base 64 is not part of MailerSend supported filetypes. Please refer to supported file types here.

The reply to email must be a valid email address.

The reply_to email parameter is not a valid email address, it may be missing an "@", make sure it's a valid email address without typos.

Email quota reached

The account's quota has been reached. Make sure your account has been approved so you can send more than 100 emails per month.

Among these errors, the most common one our users encounter is the email domain verification. Please make sure your email domain is verified with MailerSend before you start using it in your Courier integration.

Was this helpful?