SignatureDoesNotMatch, The request signature we calculated does not match the signature you provided
amazon-ses, amazon-web-services
Solution
I believe the problem is that you uses is an "ses-smtp-user.some_number". You see, with SES, there are two ways to send emails.
- using web service (AmazonSimpleEmailServiceClient)
- using SMTP
The user that was created was for smtp, ses-smtp-user.some_number. You are using that credential for a web service call.
My suggestion is to create a normal user (not from the SES screen), and assign SES permissions. Do note that the newly created credentials won't work with SMTP now.
If you want a credential that works with both, SMTP and web service, you may want to read up on this: http://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html#smtp-credentials-convert
Problem
I have looked at other questions on SO, all of them don't have SES and Java as part of their question. Exception ``` Exception in thread "main" com.amazonaws.AmazonServiceException: Status Code: 403, AWS Service: AmazonSimpleEmailService, AWS Request ID: 6828fb27-8972-11e3-9700-b705133266ce, AWS Error Code: SignatureDoesNotMatch, AWS Error 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. at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:773) at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:417) at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:229) at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.invoke(AmazonSimpleEmailServiceClient.java:1254) at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.listVerifiedEmailAddresses(AmazonSimpleEmailServiceClient.java:296) at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.listVerifiedEmailAddresses(AmazonSimpleEmailServiceClient.java:1132) at com.mcruiseon.server.amazonses.test.AWSJavaMailSample.verifyEmailAddress(AWSJavaMailSample.java:169) at com.mcruiseon.server.amazonses.test.AWSJavaMailSample.main(AWSJavaMailSample.java:84) ``` Source Code ``` public class AWSJavaMailSample { private static final String TO = "personalemail@gmail.com"; private static final String FROM = "admin@myproductdomain.com"; private static final String BODY = "Hello World!"; private static final String SUBJECT = "Hello World!"; public static void main(String[] args) throws IOException { AWSCredentials credentials = new ClasspathPropertiesFileCredentialsProvider() .getCredentials(); AmazonSimpleEmailService ses = new AmazonSimpleEmailServiceClient( credentials); Region usWest2 = Region.getRegion(Regions.US_EAST_1); ses.setRegion(usWest2); verifyEmailAddress(ses, FROM); // verifyEmailAddress(ses, TO); Properties props = new Properties(); props.setProperty("mail.transport.protocol", "aws"); props.setProperty("mail.aws.user", "ses-smtp-user.some_number") ; props.setProperty("mail.aws.password", "password_setup_for_this_user"); Session session = Session.getInstance(props); try { Message msg = new MimeMessage(session); msg.setFrom(new InternetAddress(FROM)); msg.addRecipient(Message.RecipientType.TO, new InternetAddress(TO)); msg.setSubject(SUBJECT); msg.setText(BODY); msg.saveChanges(); Transport t = new AWSJavaMailTransport(session, null); t.connect(); t.sendMessage(msg, null); t.close(); } catch (AddressException e) { e.printStackTrace(); System.out .println("Caught an AddressException, which means one or more of your " + "addresses are improperly formatted."); } catch (MessagingException e) { e.printStackTrace(); System.out .println("Caught a MessagingException, which means that there was a " + "problem sending your message to Amazon's E-mail Service check the " + "stack trace for more information."); } } private static void verifyEmailAddress(AmazonSimpleEmailService ses, String address) { ListVerifiedEmailAddressesResult verifiedEmails = ses .listVerifiedEmailAddresses(); if (verifiedEmails.getVerifiedEmailAddresses().contains(address)) return; ses.verifyEmailAddress(new VerifyEmailAddressRequest() .withEmailAddress(address)); System.out.println("Please check the email address " + address + " to verify it"); System.exit(0); } } ``` SES Setup - Added myproductdomain.com to Domains. - Added admin@myproductdomain.com to Email Addresses. AwsCredentials.properties - For secretKey="aws website login password" - For accesskey="https://console.aws.amazon.com/iam/home#users, security credentials, for ses-smtp-user.some_number, access key" I am trying out the "hello world" of the SES from the eclipse plugin. Should have worked right out of the box.