Send a raw MIME email
client.emailSending.sendRaw(EmailSendingSendRawParams { account_id, from, mime_message, recipients } params, RequestOptionsoptions?): EmailSendingSendRawResponse { delivered, message_id, permanent_bounces, queued }
POST/accounts/{account_id}/email/sending/send_raw
Send a raw RFC 5322 (MIME) email for the specified account. Provide the full MIME message plus the SMTP envelope (from and recipients).
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
Example:
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Example:
Send a raw MIME email
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.message_id);{
"errors": [
{
"code": 0,
"message": "message"
}
],
"messages": [
{
"code": 0,
"message": "message"
}
],
"result": {
"delivered": [
"recipient@example.com"
],
"message_id": "<aB3xK9mP2qR5sT8uV0wX1yZ4cD6fG7hJ9kL0@example.com>",
"permanent_bounces": [
"string"
],
"queued": [
"string"
]
},
"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"
],
"message_id": "<aB3xK9mP2qR5sT8uV0wX1yZ4cD6fG7hJ9kL0@example.com>",
"permanent_bounces": [
"string"
],
"queued": [
"string"
]
},
"success": true,
"result_info": {
"count": 0,
"per_page": 0,
"total_count": 0,
"cursor": "cursor",
"page": 0
}
}