我可以在 .Net 中使用 SMTP 选项发送电子邮件,但是我需要使用 .NET SDK 通过 Amazon 发送电子邮件。它给了我一个错误,说“电子邮件地址未经验证”,尽管我确定已经验证过了。顺便说一下,我正在使用测试帐户(沙盒)。
我做错了什么?还是我漏掉了什么?
以下是我的代码:
var sesClient = new AmazonSimpleEmailServiceClient("AKIAJHXXXXXXXXXXX", "RVGdbCKXILwjUIKSexKlwXXXXXXXXXXXX",Amazon.RegionEndpoint.USEast1);
var dest = new Destination
{
ToAddresses = new List<string>() { "tayfun.ural@aryxxx.com" },
CcAddresses = new List<string>() { "arif.yilmaz@aryxxx.com" }
};
var from = "tayfun.ural@aryxxx.com";
var subject = new Content("You're invited to the meeting");
var body = new Body(new Content("Please join us Monday at 7:00 PM."));
var msg = new Message(subject, body);
var request = new SendEmailRequest
{
Destination = dest,
Message = msg,
Source = from
};
var verify = sesClient.VerifyEmailAddress(new VerifyEmailAddressRequest { EmailAddress = "tayfun.ural@aryada.com" });
try
{
var response = sesClient.SendEmail(request);
}
catch (Exception ex)
{
throw ex;
}