简体   繁体   中英

Amazon SES error: The From ARN is not a valid SES identity

I am new to amazone SES and trying to set up my .net core API to send emails using SES. Here is code I`m using to send emails:

SendEmailRequest request = new SendEmailRequest();
        request.FromEmailAddress = "email@outlook.com";//verified
        //request.
        Destination destination= new Destination();
        destination.ToAddresses = new List<string> {"some verified email"};
        request.Destination = destination;
        EmailContent content = new EmailContent();
        
        content.Simple = new Message
        {
            Body = new Body
            {
                Html = new Content
                {
                    Data = $@"<html>
                    //here is some code
                    </html>"
                }
            },
            Subject = new  Content{
                Data = "some subject"
            }
        };
        request.Content = content;
        request.FromEmailAddressIdentityArn = senderArn;
        var status = await _sesClient.SendEmailAsync(request); 

This code gives me such error: The From ARN <arn:aws:ses:eu-central-1:xxxxxxxxxxxxxx> is not a valid SES identity . On AWS console emails are verified: 控制台截图

Any ideas what I`m doing wrong?

Here is .NET Code that does work. The sender has to be verified in SES. See https://docs.aws.amazon.com/ses/latest/dg/creating-identities.html .

public async void SendMessage(string text, string toAddress)
{
       var sesClient = new AmazonSimpleEmailServiceClient(RegionEndpoint.USWest2);
       var sender = "scmacdon@amazon.com";
       var emailList = new List<string>();
       emailList.Add(toAddress);

       var destination = new Destination
            {
                ToAddresses = emailList
            };

            var content = new Content
            {
                Data = text
            };

            var sub = new Content
            {
                Data = "Amazon Rekognition Report"
            };

            var body = new Body
            {
                Text = content
            };

            var message = new Message
            {
                Subject = sub,
                Body = body
            };

            var request = new SendEmailRequest
            {
                Message = message,
                Destination = destination,
                Source = sender
            };

            try
            {
                await sesClient.SendEmailAsync(request);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

Update Make sure you are using this version.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM