aliyun_api v1.1.1 AliyunAPI.Email
Link to this section Summary
Link to this section Functions
Link to this function
send(opts \\ [])
发送邮件
doc:https://help.aliyun.com/document_detail/29444.html
opts
:app
必须:to_address
必须:from_alias
必须:subject
必须:html_body
:text_body
:click_trace
true/false
Examples
## 发送纯文本
AliyunAPI.Email.send(
app: :worth,
to_address: "andywang9527@qq.com",
subject: "Hello Test from aliyun util",
text_body: "Hello Worth"
)
## 发送富文本
AliyunAPI.Email.send(
app: :worth,
to_address: "andywang9527@qq.com",
subject: "Hello Test from aliyun util",
html_body: "<h1>Hello Worth</h1><div style="color: red;">hello world</div>"
)
Return
## 发送成功
{:ok,
%{EnvId: "58678883849", RequestId: "AE53BE89-065F-4564-B13D-958D43FF5503"}}
## 发送失败, 地址格式错误
{:error, 400,
%{
body: "{"RequestId":"3067F00C-F357-415D-B17F-84F559E37CF5","HostId":"dm.aliyuncs.com","Code":"InvalidToAddress","Message":"The specified toAddress is wrongly formed."}",
error: %{
Code: "InvalidToAddress",
HostId: "dm.aliyuncs.com",
Message: "The specified toAddress is wrongly formed.",
RequestId: "3067F00C-F357-415D-B17F-84F559E37CF5"
},
headers: [
{"Date", "Sun, 17 Feb 2019 09:00:44 GMT"},
{"Content-Type", "application/json; charset=UTF-8"},
{"Content-Length", "160"},
{"Connection", "close"},
{"Access-Control-Allow-Origin", "*"},
{"Access-Control-Allow-Methods", "POST, GET, OPTIONS"},
{"Access-Control-Allow-Headers",
"X-Requested-With, X-Sequence, _aop_secret, _aop_signature"},
{"Access-Control-Max-Age", "172800"},
{"Server", "Jetty(7.2.2.v20101205)"}
]
}}
## 发送失败,其他错误
{:error, :nxdomain}