I am using AWSSES for sending email.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
AWSStaticCredentialsProvider *credentialsProvider = [[AWSStaticCredentialsProvider alloc] initWithAccessKey:My_KEY secretKey:MY_SECRET];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1
credentialsProvider:credentialsProvider];
[AWSLogger defaultLogger].logLevel = AWSLogLevelDebug;
[AWSSES registerSESWithConfiguration:configuration forKey:@"USEast1SES"];
}
Send email function
- (void) email
{
AWSSESContent *messageBody = [[AWSSESContent alloc] init];
messageBody.data = [NSString stringWithFormat: @"Test email"];
AWSSESContent *subject = [[AWSSESContent alloc] init];
subject.data = [NSString stringWithFormat: @"Feedback from User"];
AWSSESBody *body = [[AWSSESBody alloc] init];
body.text = messageBody;
AWSSESMessage *message = [[AWSSESMessage alloc] init];
message.subject = subject;
message.body = body;
AWSSESDestination *destination = [[AWSSESDestination alloc] init];
destination.toAddresses = @[EMAIL_VERIFIED];
AWSSESSendEmailRequest *ser = [[AWSSESSendEmailRequest alloc] init];
ser.source = EMAIL_VERIFIED;
ser.destination = destination;
ser.message = message;
AWSSES *ses = [AWSSES SESForKey:@"USEast1SES"];
[ses sendEmail:ser completionHandler:^(AWSSESSendEmailResponse * _Nullable response, NSError * _Nullable error) {
NSLog(@" email");
}];
}
I am getting following error
Error Domain=com.amazonaws.AWSServiceErrorDomain Code=3 "(null)" UserInfo={Type=Sender, Message=The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
The Canonical String for this request should have been
'POST
/
content-type:application/x-www-form-urlencoded; charset=utf-8
host:email.us-east-1.amazonaws.com
user-agent:aws-sdk-iOS/2.4.0 iPhone-OS/9.2 en_US
x-amz-date:20160425T063758Z
content-type;host;user-agent;x-amz-date
16cb4baebd2874efba56f725430b36a57d5efa17b3af5d9fc38856fa0f17d5e5'
The String-to-Sign should have been
'AWS4-HMAC-SHA256
20160425T063758Z
20160425/us-east-1/email/aws4_request
9d3d181a3ab229898db9d7578b7b485ad61c19e07fe14c38d35ee4ed38ef1a94'
, Code=SignatureDoesNotMatch, __text=(
"\n ",
"\n ",
"\n ",
"\n "
)}
I have been struggling with this error more than a day. Any help will be much appreciated. I couldn't find a proper documentation for this.
Note: I am able to configure AWSSES in server with same email and secret key