将 asp.net 核心 2.0 中的邮件发送到 Amazon SES

sending mail in asp.net core 2.0 to Amazon SES

我制作了一个简单的表格,当它被提交时,我希望它向我在亚马逊的 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;
       }
}