SingleSendMail

Updated at:

Sends a single email.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

dm:SingleSendMail

none

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

AccountName

string

Yes

The sender address configured in the console.

test***@example.net

AddressType

integer

Yes

The address type. Valid values:

  • 0: Random account.

  • 1: Sender address.

1

TagName

string

No

The tag created in the Direct Mail console to classify sent email batches. You can use tags to query the sending status of each email batch. If the email tracking feature is enabled, a tag is required for sending emails. The tag must be 1 to 128 characters in length and can contain letters, digits, underscores (_), and hyphens (-).

test

ReplyToAddress

boolean

Yes

Specifies whether to enable the reply-to address configured in the console. The reply-to address must be verified. Valid values: true and false.

true

ToAddress

string

Yes

The recipient addresses. You can specify up to 100 email addresses, including email groups. Separate multiple email addresses with commas (,).

test1***@example.net

Subject

string

Yes

The subject of the email. The subject can be up to 256 characters in length.

Subject

HtmlBody

string

No

The HTML body of the email.

Note: You must specify either HtmlBody or TextBody based on the email content type.

  • The size limit for URL parameters is approximately 80 KB.

  • The size limit for body parameters in the latest SDKs is approximately 8 MB. This applies to the following SDK versions or later:
    • Java 1.4.0

    • Python 3 1.4.0

    • PHP 1.4.0

body

TextBody

string

No

The text body of the email.

Note: You must specify either HtmlBody or TextBody based on the email content type.

  • The size limit for URL parameters is approximately 80 KB.

  • The size limit for body parameters in the latest SDKs is approximately 8 MB. This applies to the following SDK versions or later:
    • Java 1.4.0

    • Python 3 1.4.0

    • PHP 1.4.0

body

FromAlias

string

No

The sender alias. The alias must be less than 15 characters in length.

Example: If the sender alias is set to "Jane" and the sender address is test***@example.net, the recipient sees the sender address as "Jane" test***@example.net.

Jane

ReplyAddress

string

No

The reply-to address.

test2***@example.net

ReplyAddressAlias

string

No

The alias of the reply-to address.

Jane

ClickTrace

string

No

Specifies whether to enable the data tracking feature. Valid values:

  • 1: Enables the data tracking feature.

  • 0: Disables the data tracking feature. This is the default value.

0

UnSubscribeLinkType

string

No

The unsubscribe link type. Valid values:

  • disabled: Does not generate an unsubscribe link.

  • default: Uses the default policy. An unsubscribe link is generated when emails are sent from a bulk sender address to specific domains, such as those containing the keywords "gmail", "yahoo", "google", "aol.com", "hotmail", "outlook", and "ymail.com". For more information, see Unsubscribe link generation and filtering mechanism. The display language is automatically identified based on the recipient's browser settings.

default

UnSubscribeFilterLevel

string

No

The filtering level. For more information, see Unsubscribe link generation and filtering mechanism. Valid values:

  • disabled: Does not filter.

  • default: Uses the default policy. Bulk sender addresses are filtered at the sender address level.

  • mailfrom: Filters at the sender address level.

  • mailfrom_domain: Filters at the sender domain level.

  • edm_id: Filters at the account level.

mailfrom_domain

Headers

string

No

The email header settings.

Both standard and non-standard fields must comply with the standard syntax requirements for headers. When sending emails through the API, you can pass up to 10 headers by using the headers field. Headers that exceed the limit are ignored. SMTP has no such limit.

  1. Standard fields

Message-ID, List-Unsubscribe, and List-Unsubscribe-Post.

Standard fields overwrite the original values in the email headers.

  1. Non-standard fields

Non-standard fields are case-insensitive.

a. Fields that start with X-User-: These fields are not pushed to EventBridge (EB) or Message Service (MNS). This is an API-only requirement. SMTP allows any custom fields.

b. Fields that start with X-User-Notify-: These fields are pushed to EB and MNS. Both API and SMTP support these fields.

When pushed to EB or MNS, the header field includes these fields.

{ "Message-ID": "", "X-User-UID1": "UID-1-000001", "X-User-UID2": "UID-2-000001", "X-User-Notify-UID1": "UID-3-000001", "X-User-Notify-UID2": "UID-4-000001" }

IpPoolId

string

No

The ID of the dedicated IP address pool. Users who have purchased dedicated IP addresses can use this parameter to specify the outbound IP address for the current email sending task. For more information, see Dedicated IP addresses.

e4xxxxxe-4xx0-4xx3-8xxa-74cxxxxx1cef

Attachments

array<object>

No

This parameter is supported only in the latest SDKs. OpenAPI and signature mechanisms do not support this parameter. For more information, see How do I send emails with attachments by using SDKs?.

object

No

This parameter is supported only in the latest SDKs. OpenAPI and signature mechanisms do not support this parameter.

AttachmentName

string

No

This parameter is supported only in the latest SDKs. OpenAPI and signature mechanisms do not support this parameter.

test.txt

AttachmentUrl

string

No

This parameter is supported only in the latest SDKs. OpenAPI and signature mechanisms do not support this parameter.

C:\Users\Downloads\test.txt

Template

object

No

The template information for sending emails by using a template.

When a template is used, the values of Subject, HtmlBody, and TextBody are ignored.

TemplateId

string

No

The template ID.

123456

TemplateData

object

No

The template variables and their values.

{"name":"Tom","age":"22"}

string

No

The template variable parameters and their values.

{ "name": "Tom", "age": "22" }

BccAddress

string

No

  • The list of blind carbon copy (BCC) recipients for the email.

  • The system sends a copy of the main email to each BCC address. The BCC information is invisible to all recipients, including those in ToAddress and BccAddress.

  • To protect the privacy of BCC recipients, email tracking features are disabled by default for emails sent to BCC recipients. This means the system does not record behavioral data such as open rates and click-through rates for BCC emails. However, billing for the sending volume, sending details, and sending status statistics are the same as those for normal emails.

  • You can specify up to two BCC recipients for each sending task.

Note: The SingleSendMail operation does not support the CC field. To use the CC feature, send emails by using SMTP.

1@example.com,2@example.com

DomainAuth

boolean

No

Specifies whether to enable domain-level authentication. Valid values:

  • true

  • false

This parameter is used only for domain-level authentication. Ignore this parameter for sender address-level authentication.

  1. Create the domain-auth-created-by-system@example.com address in the console. Keep the prefix before the @ symbol unchanged and use your own domain name as the suffix.

API scenario

Set AccountName to the custom sender address of the domain. The recipient sees the custom sender address as the sender.

SMTP scenario

a. Call the ModifyPWByDomain operation to set the domain password.

b. Authenticate by using the domain name and the configured password. Set the actual sender mailfrom to a custom address, such as user@example.com. The recipient sees user@example.com as the sender.

true

Response elements

Element

Type

Description

Example

object

EnvId

string

The event ID.

600000xxxxxxxxxx642

RequestId

string

The request ID.

2D086F6-xxxx-xxxx-xxxx-006DED011A85

Examples

Success response

JSON format

{
  "EnvId": "600000xxxxxxxxxx642",
  "RequestId": "2D086F6-xxxx-xxxx-xxxx-006DED011A85"
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidReceiverName.Malformed The format of the receiver name is invalid. It must contain the @ sign. The domain must only contain numbers, letters, underscores, minus signs, and periods. The account name must only contain numbers, letters, underscores, minus signs, and periods. The format of the receiver name is invalid. It must contain the @ sign. The domain must only contain numbers, letters, underscores, minus signs, and periods. The account name must only contain numbers, letters, underscores, minus signs, and periods.
404 InvalidMailAddress.NotFound The specified mail address is not found. The specified mail address is not found.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.