SingleSendMail

更新时间:
复制 MD 格式

Send 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 Direct Mail console.

test***@example.net

AddressType

integer

Yes

The address type. Valid values:

0: A random account.

1: A sender address.

1

TagName

string

No

A tag for categorizing email batches, which you can create in the Direct Mail console. Tags allow you to query the sending status of each batch and are required if you enable email tracking. The tag must be 1 to 128 characters long and can contain letters, digits, underscores (_), and hyphens (-).

test

ReplyToAddress

boolean

Yes

Specifies whether to use the default reply-to address configured in the console. This address must be verified. Valid values: true, false.

true

ToAddress

string

Yes

The destination email address(es). To specify multiple addresses, separate them with commas (up to 100).

test1***@example.net

Subject

string

Yes

The subject of the email, with a maximum length of 256 characters.

Subject

HtmlBody

string

No

The HTML body of the email.

Note: You must specify either HtmlBody or TextBody.

  • The size of the body is limited to approximately 80 KB when passed as a URL parameter.

  • For recent SDKs (Java 1.4.0+, Python 3 1.4.0+, and PHP 1.4.0+), the request body is limited to approximately 8 MB.

body

TextBody

string

No

The text body of the email.

Note: You must specify either HtmlBody or TextBody.

  • The size of the body is limited to approximately 80 KB when passed as a URL parameter.

  • For recent SDKs (Java 1.4.0+, Python 3 1.4.0+, and PHP 1.4.0+), the request body is limited to approximately 8 MB.

body

FromAlias

string

No

The sender name. It must be 15 characters or shorter.

For example, if you set the sender name to "Xiaohong" and the sender address is test***@example.net, the recipient sees the sender as "Xiaohong" <test***@example.net>.

小红

ReplyAddress

string

No

The reply-to address.

test2***@example.net

ReplyAddressAlias

string

No

The name displayed for the reply-to address.

小红

ClickTrace

string

No

Specifies whether to enable click tracking. Valid values: "1" enables click tracking, and "0" disables it (default).

0

UnSubscribeLinkType

string

No

disabled: Does not generate an unsubscribe link.

default: Uses the default policy. For batch sender addresses, an unsubscribe link is generated when sending to specific domains containing keywords such as "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 determined based on the recipient's browser settings.

default

UnSubscribeFilterLevel

string

No

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

disabled: No filtering.

default: Uses the default policy. For batch addresses, filtering is applied 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

Custom email header settings.

Both standard and non-standard fields must comply with standard header syntax. You can specify up to 10 headers for an API call. Excess headers are ignored. This limit does not apply to SMTP.

1. Standard fields

Message-ID, List-Unsubscribe, List-Unsubscribe-Post

Standard fields overwrite existing values in the email header.

2. Non-standard fields

Case-insensitive.

a. Fields starting with X-User-: These are not pushed to EventBridge or Message Service (MNS). This prefix is required only for API calls, not for SMTP.

b. Fields starting with X-User-Notify-: These are pushed to EventBridge and MNS. This is supported for both API and SMTP calls.

When pushed to EventBridge or MNS, the header object will contain 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 pool. If you have purchased dedicated IPs, you can use this parameter to select which dedicated IP pool to use for sending the email. For more information, see Dedicated IP.

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

Attachments

array<object>

No

This feature is available only through the latest SDKs. It is not supported for OpenAPI calls or signature-based authentication. For more information, see How do I send an email with an attachment by using an SDK?.

object

No

An object representing a single attachment.

AttachmentName

string

No

The filename of the attachment.

test.txt

AttachmentUrl

string

No

The local file path of the attachment that the SDK will use.

C:\Users\Downloads\test.txt

Template

object

No

The template information for sending a templated email.

TemplateId

string

No

The template ID.

xxx

TemplateData

object

No

The variables and their values for the template.

string

No

The parameters and values of the template variables.

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

BccAddress

string

No

  • A comma-separated list of BCC recipients.

  • The system sends a copy of the email to each BCC recipient. The BCC information is hidden from all recipients, including those specified in ToAddress and BccAddress.

  • To protect privacy, email tracking features (such as open and click tracking) are disabled for emails sent to BCC recipients. However, billing and sending status are still tracked.

  • A maximum of two BCC recipients are allowed per request.

Note: The SingleSendMail API operation does not support a CC field. To send carbon copies, use SMTP.

1@example.com,2@example.com

DomainAuth

boolean

No

Specifies whether to enable domain-level authentication.

  • true

  • false

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

1. Create the address domain-auth-created-by-system@example.com in the console. The prefix must be fixed, and the suffix must be your domain.

2.

API scenario

Set AccountName to your domain. Recipients will see the sender as domain-auth-created-by-system@example.com.

SMTP scenario

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

b. Authenticate with the domain and the configured password. Pass a custom address, such as user@example.com, as the actual sender in the MAIL FROM command. Recipients will see user@example.com as the sender.

true

Response elements

Element

Type

Description

Example

object

EnvId

string

Event ID.

600000xxxxxxxxxx642

RequestId

string

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.