Jua*_*nma 1 c# amazon-web-services amazon-ses .net-core
我制作了一个简单的表单,提交后,我希望它向我在亚马逊的 SES 提供商发送邮件。我怎样才能实现这一点?.NET Core 2.0 中是否有一个允许发送邮件的库?
顺便说一句:我在前端使用 Angular,在后端使用 WebAPI。
是的,您可以非常轻松地实现这一点,因为 AWSSDK 完全支持 .net Core 2.0。
安装AWSSDK.SimpleEmail。
然后:
public async Task<bool> SendEmail(string from, string to, string subject, string html){
// might want to provide credentials
using(var ses = new AmazonSimpleEmailServiceClient(RegionEndpoint.USEast1))
{
var sendResult = await ses.SendEmailAsync(new SendEmailRequest
{
Source = from,
Destination = new Destination(to) { CcAddresses = "if you need them", BccAddresses = "or these" },
Message = new Message
{
Subject = new Content(subject),
Body = new Body
{
Html = new Content(html)
}
}
});
return sendResult.HttpStatusCode == HttpStatusCode.OK;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3102 次 |
| 最近记录: |