Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SendEmailAsync throws incorrect exception #3526

Closed
1 task
lonix1 opened this issue Oct 25, 2024 · 8 comments
Closed
1 task

SendEmailAsync throws incorrect exception #3526

lonix1 opened this issue Oct 25, 2024 · 8 comments
Assignees
Labels
bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made. module/sdk-generated p2 This is a standard priority issue response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. service-api This issue is due to a problem in a service API, not the SDK implementation.

Comments

@lonix1
Copy link

lonix1 commented Oct 25, 2024

Describe the bug

SESv2: SendEmailAsync is supposed to throw MailFromDomainNotVerifiedException for a mail sent from an unverified domain.

However it actually throws a MessageRejectedException:

Amazon.SimpleEmailV2.Model.MessageRejectedException: Email address is not verified. The following identities failed the check in region MY-REGION: Foo Bar <[email protected]>

Since we use the exceptions to determine what failed, our code responds to failure incorrectly. This is obviously a problem.

I hope the other exceptions are working as intended.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

To work as documented.

Current Behavior

Throws incorrect exception.

Reproduction Steps

Send a mail via SendEmailAsync using an unverified domain.

Possible Solution

No response

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

AWSSDK.SimpleEmailV2 3.7.403.1

Targeted .NET Platform

.NET 8

Operating System and version

linux

@lonix1 lonix1 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 25, 2024
@bhoradc bhoradc added needs-reproduction This issue needs reproduction. module/sdk-generated p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Oct 25, 2024
@bhoradc bhoradc self-assigned this Oct 25, 2024
@bhoradc
Copy link

bhoradc commented Oct 25, 2024

Hello @lonix1,

Thank you for reporting the issue. I am able to reproduce this scenario using below minimal code sample.

AWSSDK.SimpleEmailV2 - 3.7.403.4

static async Task Main(string[] args)
{
    AmazonSimpleEmailServiceV2Client _sesClient = new AmazonSimpleEmailServiceV2Client();
    var request = new SendEmailRequest
    {
        FromEmailAddress = "[email protected]",
        Destination = new Destination { ToAddresses = new List<string> { "[email protected]" } },
        Content = new EmailContent
        {
            Simple = new Message
            {
                Subject = new Content { Data = "This is Test email" },
                Body = new Body
                {
                    Html = new Content { Data = "This is HTML Content" },
                    Text = new Content { Data = "This is Text Content" }
                }
            }
        },
    };
    try
    {
        var response = await _sesClient.SendEmailAsync(request);
        Console.WriteLine(response.MessageId);
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex);
    }
}

Exception:

Amazon.SimpleEmailV2.Model.MessageRejectedException: Email address is not verified. The following identities failed the check in region US-EAST-1: [email protected]
 ---> Amazon.Runtime.Internal.HttpErrorResponseException: Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown.

I will review it with the team to further investigate the issue.

Regards,
Chaitanya

@bhoradc bhoradc added needs-review and removed needs-reproduction This issue needs reproduction. labels Oct 25, 2024
@bhoradc bhoradc removed their assignment Oct 25, 2024
@ashishdhingra
Copy link
Contributor

Per SESv2 > SendEmail, this service API throws below errors:

AccountSuspendedException
The message can't be sent because the account's ability to send email has been permanently restricted.

HTTP Status Code: 400

BadRequestException
The input you provided is invalid.

HTTP Status Code: 400

LimitExceededException
There are too many instances of the specified resource type.

HTTP Status Code: 400

MailFromDomainNotVerifiedException
The message can't be sent because the sending domain isn't verified.

HTTP Status Code: 400

MessageRejected
The message can't be sent because it contains invalid content.

HTTP Status Code: 400

NotFoundException
The resource you attempted to access doesn't exist.

HTTP Status Code: 404

SendingPausedException
The message can't be sent because the account's ability to send email is currently paused.

HTTP Status Code: 400

TooManyRequestsException
Too many requests have been made to the operation.

HTTP Status Code: 429

SimpleEmailV2 package in AWS .NET SDK is automatically generated from the service API models. Perhaps, we need to open ticket with SES service team to advise further.

Thanks,
Ashish

@ashishdhingra ashishdhingra added service-api This issue is due to a problem in a service API, not the SDK implementation. and removed needs-review labels Oct 25, 2024
@ashishdhingra
Copy link
Contributor

Internal ticket with service team: P164679864

@ashishdhingra
Copy link
Contributor

ashishdhingra commented Oct 25, 2024

@lonix1 Good morning. Thanks for reporting the issue. Even though I have opened an issue with service team, I would request to verify some information.

Per SendEmail, MailFromDomainNotVerifiedException is thrown when The message can't be sent because the sending domain isn't verified.. Sending domain is email domain of sender, not destination.

In our reproduction code below:

static async Task Main(string[] args)
{
    AmazonSimpleEmailServiceV2Client _sesClient = new AmazonSimpleEmailServiceV2Client();
    var request = new SendEmailRequest
    {
        FromEmailAddress = "[email protected]",
        Destination = new Destination { ToAddresses = new List<string> { "[email protected]" } },
        Content = new EmailContent
        {
            Simple = new Message
            {
                Subject = new Content { Data = "This is Test email" },
                Body = new Body
                {
                    Html = new Content { Data = "This is HTML Content" },
                    Text = new Content { Data = "This is Text Content" }
                }
            }
        },
    };
    try
    {
        var response = await _sesClient.SendEmailAsync(request);
        Console.WriteLine(response.MessageId);
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex);
    }
}

it gave exception:

Amazon.SimpleEmailV2.Model.MessageRejectedException: Email address is not verified. The following identities failed the check in region US-EAST-1: [email protected]
 ---> Amazon.Runtime.Internal.HttpErrorResponseException: Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown.

The SES service is complaining about the destination email address [email protected], not the sender domain.

Please confirm the following:

  • Share self-contained reproducible code, if different from what we used to reproduce your scenario.
  • Could you please check what happens when you specify valid destination domain and/or email address?
  • Do you have the sample use case where your sender domain/email identity in SES is not verified?

Please also check Creating and verifying identities in Amazon SES for domain verification and verifying email identities. It talks about domain verification, may be in your use case, it's not done.

Thanks,
Ashish

@ashishdhingra ashishdhingra added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Oct 25, 2024
@ashishdhingra ashishdhingra self-assigned this Oct 25, 2024
@ashishdhingra
Copy link
Contributor

@lonix1 Received below communication from SES service team:


This error is supposed to be thrown when the custom MAIL FROM domain on the identity is not verified. Custom MAIL FROM domain verification is different than domain verification: https://docs.aws.amazon.com/ses/latest/dg/mail-from.html

The docs for V1 mentions this: https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/SimpleEmail/TMailFromDomainNotVerifiedException.html

The response of "Message rejected: Email address not verified" is therefore expected when they are using an unverified identity to send emails. If cx is using account in sandbox mode, both sender and recipient needs to be verified. If they are in production, they need to verify the sender domain/email only.

Thanks,
Ashish

@ashishdhingra ashishdhingra added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Oct 25, 2024
Copy link

github-actions bot commented Nov 5, 2024

This issue has not received a response in 5 days. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Nov 5, 2024
@ashishdhingra ashishdhingra closed this as not planned Won't fix, can't repro, duplicate, stale Nov 8, 2024
Copy link

github-actions bot commented Nov 8, 2024

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@lonix1
Copy link
Author

lonix1 commented Nov 14, 2024

Hi @ashishdhingra sorry for the late response,

I think we are misunderstanding each other. I used similar code to yours and got the same result. I understand the difference between sender and receiver.

The issue if I remember correctly is this:

MailFromDomainNotVerifiedException

The message can't be sent because the sending domain isn't verified.

MessageRejectedException

The message can't be sent because it contains invalid content.

But as you and @bhoradc verified in your own code, if you send from an unverified domain, it throws the latter instead of the former.

We've moved on from this issue, but from what I can tell either 1) it is throwing the wrong exception, or 2) the docs must be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made. module/sdk-generated p2 This is a standard priority issue response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. service-api This issue is due to a problem in a service API, not the SDK implementation.
Projects
None yet
Development

No branches or pull requests

3 participants