Skip to content
Start here

Send a raw MIME email message.

client.emailSending.sendRaw(EmailSendingSendRawParams { account_id, from, mime_message, recipients } params, RequestOptionsoptions?): EmailSendingSendRawResponse { delivered, permanent_bounces, queued }
POST/accounts/{account_id}/email/sending/send_raw

Send a raw MIME email message.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
ParametersExpand Collapse
params: EmailSendingSendRawParams { account_id, from, mime_message, recipients }
account_id: string

Path param: Identifier of the account.

from: string

Body param: Sender email address.

formatemail
mime_message: string

Body param: The full MIME-encoded email message. Should include standard RFC 5322 headers such as From, To, Subject, and Content-Type. The from and recipients fields in the request body control SMTP envelope routing; the From and To headers in the MIME message control what the recipient's email client displays.

recipients: Array<string>

Body param: List of recipient email addresses.

ReturnsExpand Collapse
EmailSendingSendRawResponse { delivered, permanent_bounces, queued }
delivered: Array<string>

Email addresses to which the message was delivered immediately.

permanent_bounces: Array<string>

Email addresses that permanently bounced.

queued: Array<string>

Email addresses for which delivery was queued for later.

Send a raw MIME email message.

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

const response = await client.emailSending.sendRaw({
  account_id: 'account_id',
  from: 'sender@example.com',
  mime_message:
    'From: sender@example.com\r\nTo: recipient@example.com\r\nSubject: Hello\r\nContent-Type: text/plain\r\n\r\nHello, World!',
  recipients: ['recipient@example.com'],
});

console.log(response.delivered);
{
  "errors": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "messages": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "result": {
    "delivered": [
      "recipient@example.com"
    ],
    "permanent_bounces": [
      "dev@stainless.com"
    ],
    "queued": [
      "dev@stainless.com"
    ]
  },
  "success": true,
  "result_info": {
    "count": 0,
    "per_page": 0,
    "total_count": 0,
    "cursor": "cursor",
    "page": 0
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "messages": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "result": {
    "delivered": [
      "recipient@example.com"
    ],
    "permanent_bounces": [
      "dev@stainless.com"
    ],
    "queued": [
      "dev@stainless.com"
    ]
  },
  "success": true,
  "result_info": {
    "count": 0,
    "per_page": 0,
    "total_count": 0,
    "cursor": "cursor",
    "page": 0
  }
}