# Email

# Send an email

This endpoint allows you to send email.

# Request

POST https://api.mailersend.com/v1/email

# Request Body

{
  "from": {
    "email": "hello@mailersend.com",
    "name": "MailerSend"
  },
  "to": [
    {
      "email": "john@mailersend.com",
      "name": "John Mailer"
    }
  ],
  "subject": "Hello from {$company}!",
  "text": "This is just a friendly hello from your friends at {$company}.",
  "html": "<b>This is just a friendly hello from your friends at {$company}.</b>",
  "variables": [
    {
      "email": "john@mailersend.com",
      "substitutions": [
        {
          "var": "company",
          "value": "MailerSend"
        }
      ]
    }
  ]
}

# Request Body Parameters

JSON parameters are provided in dot notation

JSON Parameter Type Required Limitations Details
from object yes * not required if template_id is present and template has default sender set
from.email string yes * Must be a verified domain not required if template_id is present and template has default sender set
from.name string no from.email will be used if not provided or if template_id is present with default values, the default subject from that will be used
to object[] yes Min 1, max TBD
to.*.email string yes
to.*.name string no The name of the recipient. May not contain ; or ,
reply_to.email string no
reply_to.name string no
subject string yes * not required if template_id is present and template has default subject set
text string yes * Email represented in a text (text/plain) format. * Only required if there's no template_id present.
html string yes * Email represented in HTML (text/html) format. * Only required if there's no template_id present.
attachments object[] no
attachments.*.content string yes Base64 encoded content of the attachment
attachments.*.filename string yes
attachments.*.id string no Can be used in content as an <img/> tag. TBD
template_id string no
tags string[] no
variables object[] no These will be replaced in the email content using {$var} format. Can be used in the subject, html, text fields.
variables.*.email string yes Email address that substitutions will be applied to.
variables.*.substitutions object[] yes
variables.*.substitutions.*.var string yes Name of the variable, will replace {$var} in the subject, html, text fields.
variables.*.substitutions.*.value string yes Value to be replaced, based on the variables.*.substitutions.*.var name

# Responses

# Sending queued

Response Code: 202 Accepted
Response Headers:
	Content-Type: text/plain; charset=utf-8
	X-Message-Id: 5e42957d51f1d94a1070a733
Response Body: [EMPTY]

# Sending paused

Response Code: 202 Accepted
Response Headers:
	Content-Type: text/plain; charset=utf-8
	X-Message-Id: 5e42957d51f1d94a1070a733
  X-Send-Paused: true
Response Body: [EMPTY]

# Validation error

Response Code: 422 Unprocessable Entity
Response Headers:
	Content-Type: application/json
{
  "message": "The given data was invalid.",
  "errors": {
    "from.email": [
      "The from.email must be verified."
    ]
  }
}

See - Validations Errors

# Validation warning

Response Code: 202 Accepted
Response Headers:
	Content-Type: application/json
	X-Message-Id: 5e42957d51f1d94a1070a733
{
  "message": "There are some warnings for your request.",
  "warnings": [
  	{
  		"type": "Suppressions",
  		"recipients": [
    		"suppressed@recipient.com"
  		]
  	}
  ]
}
Last Updated: 10/5/2020, 2:54:42 PM