tencent cloud

Feedback

SendEmail

Last updated: 2023-06-12 16:22:42

1. API Description

Domain name for API request: ses.tencentcloudapi.com.

This API is used to send an HTML or TEXT email triggered for authentication or transaction. By default, you can send emails using a template only.

A maximum of 20 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: SendEmail.
Version Yes String Common Params. The value used for this API: 2020-10-02.
Region Yes String Common Params. For more information, please see the list of regions supported by the product.
FromEmailAddress Yes String Sender address. Enter a sender address, for example, noreply@mail.qcloud.com.
To display the sender name, enter the address in the following format:
Sender
Destination.N Yes Array of String Recipient email addresses. You can send an email to up to 50 recipients at a time. Note: the email content will display all recipient addresses. To send one-to-one emails to several recipients, please call the API multiple times to send the emails.
Subject Yes String Email subject.
ReplyToAddresses No String Reply-to address. You can enter a valid personal email address that can receive emails. If this parameter is left empty, reply emails will fail to be sent.
Cc.N No Array of String
Bcc.N No Array of String
Template No Template Template parameters for template-based sending. As Simple has been disused, Template is required.
Simple No Simple Disused
Attachments.N No Array of Attachment Parameters for the attachments to be sent. The TencentCloud API supports a request packet of up to 8 MB in size, and the size of the attachment content will increase by 1.5 times after Base64 encoding. Therefore, you need to keep the total size of all attachments below 4 MB. If the entire request exceeds 8 MB, the API will return an error.
Unsubscribe No String Unsubscribe link option. 0: Do not add unsubscribe link; 1: English 2: Simplified Chinese; 3: Traditional Chinese; 4: Spanish; 5: French; 6: German; 7: Japanese; 8: Korean; 9: Arabic; 10: Thai
TriggerType No Integer Email triggering type. 0 (default): non-trigger-based, suitable for marketing emails and non-immediate emails; 1: trigger-based, suitable for immediate emails such as emails containing verification codes. If the size of an email exceeds a specified value, the system will automatically choose the non-trigger-based type.

3. Output Parameters

Parameter Name Type Description
MessageId String Unique ID generated when receiving the message
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

Example1 Sending a plain text email

Input Example

POST / HTTP/1.1
Host: ses.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: SendEmail
<Common request parameters>

{
    "FromEmailAddress": "QCLOUDTEAM <noreply@mail.qcloud.com>",
    "ReplyToAddresses": "qcloud@tencent.com",
    "Destination": [
        "user@example.com"
    ],
    "Simple": {
        "Text": "aGVsbG8gd29ybGQ="
    },
    "Subject": "YourTestSubject"
}

Output Example

{
    "Response": {
        "RequestId": "8979fc1e-9564-4fc9-bf7d-2958ce679b72",
        "MessageId": "qcloud-ses-messageid"
    }
}

Example2 Sending a rich text email

Input Example

POST / HTTP/1.1
Host: ses.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: SendEmail
<Common request parameters>

{
    "FromEmailAddress": "QCLOUDTEAM <noreply@mail.qcloud.com>",
    "ReplyToAddresses": "qcloud@tencent.com",
    "Destination": [
        "user@example.com"
    ],
    "Simple": {
        "Html": "PGh0bWw+PGRpdj5IZWxsb1dvcmxkPC9kaXY+PC9odG1sPg==",
        "Text": "aGVsbG8gd29ybGQ="
    },
    "Subject": "YourTestSubject"
}

Output Example

{
    "Response": {
        "RequestId": "8979fc1e-9564-4fc9-bf7d-2958ce679b72",
        "MessageId": "qcloud-ses-messageid"
    }
}

Example3 Sending an email by using a template

Input Example

POST / HTTP/1.1
Host: ses.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: SendEmail
<Common request parameters>

{
    "FromEmailAddress": "QCLOUDTEAM <noreply@mail.qcloud.com>",
    "ReplyToAddresses": "qcloud@tencent.com",
    "Destination": [
        "user@example.com"
    ],
    "Template": {
        "TemplateID": "100091",
        "TemplateData": "{\"code\":\"1234\"}"
    },
    "Subject": "YourTestSubject"
}

Output Example

{
    "Response": {
        "RequestId": "8979fc1e-9564-4fc9-bf7d-2958ce679b72",
        "MessageId": "qcloud-ses-messageid"
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
FailedOperation.AttachContentToolarge The attachments are too large. Make sure they do not exceed the size limit for a single attachment and the overall limit for all attachments.
FailedOperation.EmailAddrInBlacklist The email address is in the blocklist.
FailedOperation.EmailContentToolarge The email is too large. Remove some content.
FailedOperation.ExceedSendLimit The number of emails exceeds the daily sending limit.
FailedOperation.FrequencyLimit You have sent too many emails to the same address in a short period.
FailedOperation.HighRejectionRate The email has been blocked temporarily due to high rejection rate.
FailedOperation.IncorrectEmail Incorrect email address.
FailedOperation.IncorrectSender Incorrect sender format. Follow the sample in this document.
FailedOperation.InsufficientBalance Insufficient balance or account in arrears.
FailedOperation.InsufficientQuota Insufficient emails in plans.
FailedOperation.InvalidAttachName Unsupported attachment name. Make sure it does not contain special characters. For details, see the attachment description.
FailedOperation.InvalidTemplateID Invalid template ID or unavailable template.
FailedOperation.MissingEmailContent Missing email content (TemplateData and Simple cannot be both empty).
FailedOperation.NoAttachPermission No permission to send an email with attachments.
FailedOperation.NotAuthenticatedSender Unable to send because the sender is not verified.
FailedOperation.ProtocolCheckErr Incorrect protocol. Make sure the protocol is correct.
FailedOperation.ReceiverHasUnsubscribed The recipient has unsubscribed.
FailedOperation.RejectedByRecipients The message was rejected by the recipient.
FailedOperation.SendEmailErr Email sending error. Please submit a ticket to us for troubleshooting.
FailedOperation.TemporaryBlocked The email has been blocked temporarily due to violations of rules.
FailedOperation.TooManyAttachments Too many attachments. A single email supports up to 10 attachments.
FailedOperation.TooManyRecipients Too many recipients. Set a maximum of 50 recipients at a time.
FailedOperation.UnsupportMailType Unsupported email type.
FailedOperation.WithOutPermission You can only send emails by using a template.
FailedOperation.WrongContentJson The format of the TemplateData field is incorrect. Make sure it is in JSON format.
InternalError Internal error.
InvalidParameter Incorrect parameter.
InvalidParameterValue Invalid parameter value.
InvalidParameterValue.AttachContentIsWrong Incorrect attachment content. Make sure the base64 content is correct.
InvalidParameterValue.EmailAddressIsNULL The recipient or sender address is empty. Please check.
InvalidParameterValue.EmailContentIsWrong Incorrect email content. Make sure TEXT/HTML base64 is correct.
InvalidParameterValue.InvalidEmailIdentity Invalid domain value.
InvalidParameterValue.ReceiverEmailInvalid The recipient address is incorrect.
LimitExceeded The quota limit is exceeded.
MissingParameter Missing parameter.
OperationDenied Operation denied.
RequestLimitExceeded The number of requests exceeds the frequency limit.
ResourceInsufficient Insufficient resources.
ResourceUnavailable The resource is unavailable.
UnknownParameter Unknown parameter error.
UnsupportedOperation Unsupported operation.
Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support