This document describes simplified process of using API and SMTP to quickly send emails.
To quickly understand DirectMail, you may go through the following flowchart. Detailed explanations of corresponding nodes can be found in the document.
Open Direct Mail
1. Open by main account: Log on to the DirectMail product page, and click Buy Now to purchase DirectMail prepaid resources package. You can also click Activate Now to activate DirectMail based on the pay-as-you-go billing method.
2. Open by RAM account: Use the main account to grant AliyunDirectMailFullAccess and AliyunDirectMailReadOnlyAccess permissions to RAM account in RAM console.
Note: Please make sure that your Alibaba Cloud account has passed real-name verification first, and then you can purchase and open DirectMail.
Click here to complete real-name verification.
Select Sending Region
You can select one of the three regions: China (Hangzhou), Singapore, Germany and United States. The domain names and sender addresses of one region can be used only in that region. Sender addresses created in one region can only send emails through Console, API, or SMTP of the corresponding region.How to select the region:
1. Premise: Different regions determine the data landing region. If non-China customers are involved, please consult your legal department to select a region based on applicable data compliance laws and regulations.
2. If your email delivery application is deployed in China, we recommend that you select the China (Hangzhou) region.
3. If your sending program is deployed outside of China and most of your receiving addresses are outside of China, you are advised to select Singapore, Germany and United States.
4. If your email delivery application is deployed outside of China and most recipient addresses reside in China, please use one of the following recommendations based on your business scenario:
a. If you use an email delivery application to send emails over SMTP and the application is deployed in the US or Singapore, we recommend that you select the China (Hangzhou) region. The emails are automatically routed to the China (Hangzhou) region by using the content delivery network (CDN) nodes in the US or Singapore region.
b. For other scenarios, we recommend that you select the Singapore region.
Create and Configure Domain Name
User must create a sending domain name when using DirectMail for the first time. You can use automatic configuration or manual configuration method to configure domain name. For more information, check Step 1 to Step 4 in the Simplified Procedure of Configuring Email Delivery.
Create Sender Addresses
1. Create sender addresses: Sender addresses indicate the email address of the sender and will be displayed in emails that are received by recipients.
2. Verify return address: When you configure sender addresses, you can specify a return address to receive emails.
3. Set SMTP password: If you want to send emails over SMTP, you can set an SMTP password when you configure sender addresses.
For more information, please check Setup Sender Addresses.
Send Emails by Calling API
API endpoints: For more information, please check API endpoints.
Interfaces for email delivery: SingleSendMail and BatchSendMail.
User can use signature or SDK to call API. Alibaba Cloud provides sample code for both methods. In most cases, the SDK method is used. We will take SDK method as an example here.
Signature: For more information, please check Signature.
SDK:
1. Use OpenAPI Explorer to automatically generate code. Use OpenAPI Explorer to debug, select a programming language, configure the parameters, and download automatically generated code. You can use SDK V2.0 or V1.0. We recommend that you use the V2.0.
2. Other SDK methods. Download SDK package from SDK Reference or use Maven to install it, and then send emails based on sample code.
Note: You must specify the required values for the accessKeyId and accessKeySecret parameters in your code. The AccessKey ID and AccessKey Secret are the credentials that are used to access Alibaba Cloud API. You can create an AccessKey on the AccessKey Management page in the Alibaba Cloud Management Console.
Send Emails through SMTP
SMTP servers: SMTP EndPoints.
Examples:
The official Alibaba Cloud documentation provides code examples in multiple programming languages. For more information about how to obtain a language-specific code example, check SMTP reference. We will take Java code as an example here.
1. Configure a Java development environment and download the required code editor.
2. Find SMTP - Java, click the copy icon in the code sample section, paste the sample code in the editor, and then replace the sample parameter values with actual values.
Delivery Reports
You can use one of the following methods to view the statistics about the emails that are sent from all sender addresses under the main account:
1. Path: DirectMail-->Reporting. User can check delivery overview, delivery log and invalid addresses in this page. For more information, please check Delivery Reports.2. We provide five interfaces to query delivery overview. For details about the interfaces, please check Delivery Overview. Please refer to the information under API sending content above for call method.