DirectMail SingSendMail 不工作

DirectMail SingSendMail not working

我正在尝试使用阿里云的 DirectMail 的 singleSendMail API,请求看起来像这样

https://xx.xxxx.com/?Action=SingleSendMail
&AccountName=test@example.com
&ReplyToAddress=true
&AddressType=1   
&ToAddress=test1@example.com
&Subject=Subject
&HtmlBody=<body><h2>Test</h2></body>

我收到 400 错误 MissingParameter

阿里云 REST API 有两组参数加上您必须在请求中包含的签名。

以Python为例,需要指定public参数如下:

parameters = {}

# Add the DirectMail public request parameters
parameters["Format"] = "json"
parameters["AccessKeyId"] = credentials['AccessKey']
parameters["SignatureMethod"] = "HMAC-SHA1"
parameters["SignatureType"] = ""
parameters["SignatureVersion"] = "1.0"
parameters["SignatureNonce"] = get_uuid()
parameters["Timestamp"] = utc
parameters["Version"] = "2017-06-22"
parameters["RegionId"] = "ap-southeast-1"

添加请求参数如下。您将需要修改您的帐户信息:

# Add parameters that are always set
parameters["Action"] = "SingleSendMail"
parameters["AddressType"] = "1"
parameters["ReplyToAddress"] = "true"

# Add the DirectMail API parameters
parameters["AccountName"] = dm_account
parameters["FromAlias"] = dm_alias
parameters["ToAddress"] = to_list
parameters["Subject"] = subject
parameters["HtmlBody"] = body
parameters["textBody"] = body_text

然后您需要签署请求。

我在 Python 中写了一篇关于直邮和生成带有完整工作源代码的签名的文章。

DirectMail REST API