Send email using the API.

REST Methods

Note: API is case sensitive. Make all parameters entries lower case. All parameters in red are required.

Note: Write actions (POST, UPDATE, DELETE) may take several minutes to propagate and be reflected by the API. If a subsequent read request fails to reflect your changes, please wait a few minutes and try again.

VERB RESOURCE PARAMETERS DESCRIPTION
POST /send
  • apikey
  • from
  • to
  • subject
  • replyto
  • cc
  • bcc
  • sender
  • messageid
  • inreplyto
  • references
  • comments
  • keywords
  • replyby
  • importance
  • priority
  • sensitivity
  • resent-date
  • resent-from
  • resent-sender
  • resent-replyto
  • resent-messageid
  • bodytext
  • bodyhtml
  • xheaders
  • content-encoding
Sends email.
 

POST /send

Sending Email using the API requires specific syntax for the REST API.

Parameters

  • apikeyRequired. API key of the account which will send the message.
  • fromRequired. Sender email address — This can either be an email address or a properly formatted from header (example: “From Name” <example@email.com>)
  • toRequired. Address(es) the email will be sent to — This can either be an email address or a properly formatted from header (example: “To Name” <example@email.com>). For multiple addresses, specify a query string array like so: to[]=first@recipient.com&to[]=second@recipient.com&to[]=etc… Brackets are not required for a single recipient. Example: to=only@recipient.com. The tofield in the email will contain all the addresses when it is sent out and will be sent to all the addresses.
  • subjectRequired. The subject of the email being sent.
  • replyto — The email address for the recipient to reply to. If left blank, defaults to the from address. The format can either be an email address or a properly formatted from header (example: “From Name” <example@email.com>).
  • cc — Address(es) to copy the email to — This can either be an email address or a properly formatted cc header (example: “cc Name” <example@email.com>). For multiple addresses, specify a query string array like so: cc[]=first@recipient.com&cc[]=second@recipient.com&cc[]=etc… Brackets are not required for a single recipient. Example: cc=only@recipient.com.
  • bcc — Address(es) to blind copy the email to — This can either be an email address or a properly formatted bcc header (example: “bcc Name” <example@email.com>). For multiple addresses, specify a query string array like so: bcc[]=first@recipient.com&bcc[]=second@recipient.com&bcc[]=etc… Brackets are not required for a single recipient. Example: bcc=only@recipient.com
  • sender — This is the email address of the agent responsible for sending the message. This is an optional header and only relevant when the ‘from’ email address is different to the ‘sender’ email address.
  • messageid — A unique message identifier that can be passed in via the api and override the Dyn automatically generated message id.
  • inreplyto — One or more message identifier(s) of the original message(s) to which the current message is a reply.
  • references — The message identifier(s) of other message(s) to which the current message may be related.
  • comments — Additional comments about the message.
  • keywords — A comma-separated list of important words and phrases useful for recipient.
  • replyby — The date and time by which a reply is requested. Date-time should be in local time format such as Thu, 13 Feb 2013 23:32:54 -0330.
  • importance — A hint from the originator on how important the message is. Can take values of either high, normal or low. Not related to transmission speed.
  • priority — Values are either normal, urgent, or non-urgent. This header can influence transmission speed and delivery.
  • sensitivity — How sensitive it is to disclose this message with values that can be either personal, private or company confidential.
  • resent-date — The date and time that a message is resent in the same format as replyby.
  • resent-from — The email address of the person who has resent the message, or on whose behalf the message has been resent.
  • resent-sender — The email address of the person who has resent the message, if this is different from the resent-from value.
  • resent-replyto — Resent Reply-to in the same format as the replyto header.
  • resent-messageid — Contains a message identifier for a resent message.
  • bodytext — The plain/text version of the email; this field may be encoded in Base64 (not recommended), quoted-printable, 8-bit, or 7-bit.
    NOTE: Even though bodytext and bodyhtml are both optional, at least one of them must be provided for the email to be valid.
  • bodyhtml — The text/html version of the email; this field may be encoded in 7-bit, 8-bit, quoted-printable, or base64.
    NOTE: Even though bodytext and bodyhtml are both optional, at least one of them must be provided for the email to be valid.
  • xheaders — Any additional custom X-headers to send in the email — Pass the X-header’s name as the field name and the X-header’s value as the value (example: x-demonheader=zoom).NOTE:
    When setting X-Header values, it is important to avoid using the greater than (<) and lesser than (>) symbols in your X-Header values. A valid X-Header value looks like this: “some_xheader_value_string_here”
  • content-encoding – The encoding type used for the provided content. If a valid value is specified, Dyn will skip automatic detection of the content. If not specified, or an invalid is value given, the system will attempt to detect encoding. Valid values: quoted-printable, base64, 8bit, or 7bit.

Please see RFC4021 for further details. 

Encode special UTF-8 characters into the display name

The Send API supports special characters such as international and other UTF-8 characters (including emojis) in the display name for the From, To, CC, BCC fields, and the Subject line.

According to the SMTP RFC specification for such characters (RFC 2047), special characters need to be encoded into Base64 encoding with the required UTF-8 character set, and the encoded value is included in a special “encoded-word” format.

To encode special UTF-8 characters into the display name:

1. Start with an unencoded sender display name (such as “爱情” or “❤️”). The display name can include both special and regular ASCII characters.
2. Encode the complete display name string to Base64 including the UTF-8 specified as the character set.
3. According to RFC 2047, assemble the “encoded-word” for the sender display name in the following format:
      “=?” [charset] “?” [encoding] “?” [encoded-text] “?=”
      “charset” will usually be “UTF-8” to support special characters
      “encoding” will be “B” for Base64, to again support special characters
4. For the display name of the From, To, CC, and BCC parameters, combine the encoded-word display name with the email address in the form below (angular brackets < and > must surround the email address):
[encoded-word] <sender-email-address>
5. URL-encode the complete string and provide it in the appropriate parameter value in the Send API request.
For example, for a display name of the heart emoji, the URL-encoded display name and sample From the email address would be:
=?UTF-8?B?4p2k77iP?= <sender@domain.com>

Example Request

curl --request POST "https://emailapi.dynect.net/rest/json/send" --data "apikey=ABC123XYZ&from=example@example.com&to=customer1@domain.com&to=customer2@domain.com&to=customer3@domain.com&subject=New Sale Coming Friday&bodytext=You will love this sale."

Example Results = Success (JSON)

{"response":{"status":200,"message":"OK","data":"250 2.1.0 Ok"}}

Example Results = Invalid “From” Address (JSON)

{"response":{"status":200,"message":"OK","data":"503 5.5.1 Error: need MAIL command"}}

Please see this page or RFC 3463 for a list of possible codes returned here.