Alibaba Cloud DevOps Cookbook

Day #3 - DirectMail

Date Created: May 24, 2018
Last Update: May 24, 2018

[Editor's Note: This will be a three-part series on DirectMail, Function Compute, API Gateway and calling DirectMail using the REST API including creating the REST API Signature.]

Table of Contents

Alibaba Documentation
Step 1. Enable DirectMail in the Alibaba Console
Step 2. Create DirectMail Domain
Step 3. Create DirectMail DNS Entries
Step 4. Verify DirectMail DNS Entries
Step 5. Create Sender Address

Alibaba Documentation

Alibaba DirectMail Product Page
Alibaba DirectMail Documentation
Setup Domain Names
API Reference
API: SingleSendMail
Alibaba Cloud PHP SDK
DirectMail Pricing


What is Alibaba DirectMail? DirectMail is a service for sending email and not for receiving email. For web servers, the ability to send emails is very important for most companies. DirectMail supports sending a single email as well as batch emails from an email list.

Typical uses for DirectMail are to send system notifications, user registrations, promotions, user surveys, etc.

DirectMail supports sending emails using the API and using the traditional SMTP interface. In this article, I will be demonstrating sending emails using PHP from my desktop (using Access Keys) as well as from an ECS instance (using service roles).

Step 1. Enable DirectMail in the Alibaba Console

The first step is to enable DirectMail in the Alibaba Console.

  • Login to the Alibaba Console.
  • Click on Products in the left title bar.
  • In the search bar enter Direct Mail.
  • Click on Direct Mail.
  • If you have not enabled DirectMail previously, enable it now.
  • Shortcut to the Alibaba DirectMail Console

Step 2. Create DirectMail Domain

This is the most difficult part of setting up DirectMail. You need to have access to your domain's DNS servers to create a subdomain. I will show an example using my domain (neoprime.xyz) which is hosted by Alibaba Cloud. I will create a new domain directmail.neoprime.xyz and link this to DirectMail. Replace references to neoprime.xyz with your domain name.

  1. Select the region for the DirectMail service. At this time only three regions are supported.

  2. In the DirectMail console, click on Email Domains located under Email Settings.

  3. Click the New Domain button located at the top right of the page.

  4. A dialog will open. Enter your domain name: directmail.neoprime.xyz and click OK.

  5. Your new domain will now be displayed in the console. The next step is to click on Configure

  6. A Domain Configuration screen will be displayed. You will need to create DNS records for each record displayed.

Step 3. Create DirectMail DNS Entries

Alibaba Cloud DNS requires different steps than other DNS servers such as Amazon Route 53. The steps below are for Alibaba Cloud DNS. I have also duplicated these steps using Amazon Route 53. Alibaba's steps are easier for configuring domain names, subdomain names and DNS configurations.

  1. In a separate browser window, open the Alibaba Cloud DNS console.
  2. Click on the Configure link. In the next steps we will add the DNS records.

  3. Go thru each DNS record that needs to be created from above. You will create four new records similar to these:
    • CNAME - dmtrace.directmail - tracedm-ap-southeast-1.aliyuncs.com
    • MX - directmail - mxdm-ap-southeast-1.aliyun.com
    • TXT - directmail - v=spf1 include:spfdm-ap-southeast-1.aliyun.com -all
    • TXT - aliyundm.directmail - cbcbf287e6844d7b96de

Step 4. Verify DirectMail DNS Entries

  1. Go back to the DirectMail Console window. At the bottom of the screen click the Confirm the changes blue button.

  2. To verify the DNS records that you created, click the Verify link.

  3. If the verify fails, double check that you entered the correct values for the four DNS records.

Step 5. Create Sender Address

  1. Go to Sender Addresses in the left panel. Click the Create Sender Address button.
Tip: When you create send address, the console will show verification failed. You need to respond to the email that Alibaba sends. Once you click the link in the email, the verification will complete.

15220 Main Street, Bellevue, WA 98007
T: 425-528-8500 - F: 425-528-8550 - E: neoprime@neoprime.io

Copyright 2018 NeoPrime LLC