0

I'm integrating Amazon SES SDK in my iOS app. I have recently observed that, I'm unable to send mails from a verified email address. if I switch to US_WEST_2 region. The problem seem to be with iOS SDK, as I'm able to send mail from Amazon Console using same mail address.

Error Message: exception={SESMessageRejectedException { RequestId:70ed2e9e-dc16-11e3-89ca-956987a01a60, ErrorCode:MessageRejected, Message:Email address is not verified. }}, errorCode=MessageRejected}

Code: SESManager class:

    SESSendEmailRequest *ser = [[SESSendEmailRequest alloc] init] ;

    ser.source      = strSenderMailAddress;
    ser.destination = destination;
    ser.message     = message;

    SESSendEmailResponse *response = [[AmazonClientManager ses] sendEmail:ser];

AmazonClientManager:

+(AmazonSESClient *)ses
{
    [AmazonClientManager validateCredentials];
    return ses;
}

+(void)validateCredentials
{
    if ([AmazonClientManager hasCredentials]) {

            [AmazonClientManager clearCredentials];

            ses = [[AmazonSESClient alloc] initWithAccessKey:[Lockbox stringForKey:kLockboxAmazonAccessKey] withSecretKey:[Lockbox stringForKey:kLockboxAmazonSecretKey]];

 ses.endpoint = [AmazonEndpoints sesEndpoint:@"https://email.us-west-2.amazonaws.com"];

    }
}
Gerald Schneider
  • 17,416
  • 9
  • 60
  • 78
niks
  • 544
  • 11
  • 28
  • Can you share the code snippet for instantiating an SES client and sending an email so that I can repro the issue? – Yosuke May 25 '14 at 04:18
  • Hi Yosuke, Please check code snippet. As per guideline, I have verified a new email address for US_WEST_2 region, but I'm unable to send mail using my app with that email address. But, It's working fine if, I try send mail from Amazon console using the same email address. – niks May 26 '14 at 14:19

3 Answers3

0

It sounds like what you are seeing is by design.

The regions are independent systems, like much of AWS.

You must verify each sender’s email address separately for each region you want to use.

http://docs.aws.amazon.com/ses/latest/DeveloperGuide/regions.html

Community
  • 1
  • 1
Michael - sqlbot
  • 169,571
  • 25
  • 353
  • 427
  • Thanks Michael. I have verified a new email address for US_WEST_2 region, but still I'm not able to send mail with that address using iOS SDK. I'm able to send mail from Amazon Console by selecting US_WEST_2 region & using same email address verified for that region. – niks May 19 '14 at 09:52
  • I might have misinterpreted your question. At one time, SES only had one region, us-east-1. Is your SDK version current, or is it possible that it contains an implicit assumption of only one possible region? I assume you have this under control but that's the only remaining guess I have. – Michael - sqlbot May 19 '14 at 11:01
0

sesEndpoint: takes an AmazonRegion, which is defined as follows:

typedef enum
{
    US_EAST_1      = 0,
    US_WEST_1      = 1,
    EU_WEST_1      = 2,
    AP_SOUTHEAST_1 = 3,
    AP_NORTHEAST_1 = 4,
    US_WEST_2      = 5,
    SA_EAST_1      = 6,
    AP_SOUTHEAST_2 = 7
} AmazonRegion;

You need to change this line:

ses.endpoint = [AmazonEndpoints sesEndpoint:@"https://email.us-west-2.amazonaws.com"];

to this:

ses.endpoint = [AmazonEndpoints sesEndpoint:US_WEST_2];

When you pass an invalid region, it will default to the US East 1 region. That's why you are getting the exception.

Hope this helps,

Yosuke
  • 3,759
  • 1
  • 11
  • 21
  • Thanks Yosuke. Sorry for late reply. I have tried with US_WEST_2 option also, but its not working. Also, I have tried by changing region(US_WEST_2) in SES sample code provide by Amazon, its not working in sample code also. Can you please try once by changing region in sample code. https://github.com/awslabs/aws-sdk-ios-samples/tree/master/SES_FeedbackForm – niks Jun 02 '14 at 07:12
  • The sample app works for me. What's the value of `ses.endpoint` after you assign `[AmazonEndpoints sesEndpoint:US_WEST_2]`? – Yosuke Jun 03 '14 at 08:49
0

I would suggest instead of verifying emails you look on the following issue where you can make it more Production based.

How can i send mail without verifying the recipients in amazon ses

This approach is more correct & more appropriate even though you do it for any region.

Murtaza Kanchwala
  • 2,425
  • 25
  • 33