SignatureDoesNotMatch. The request signature we signed does not match the signature you provided

I looked at other questions about SO, all of them do not 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

 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 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 by myproductdomain.com to Domains.
  • Added admin@myproductdomain.com address for email addresses.

AwsCredentials.properties

  • For secretKey = "aws 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 to "hello world" SES from the eclipse plugin. It should have worked right out of the box.

+6
source share
1 answer

I believe the problem is that you are using "ses-smtp-user.some_number". You see that with SES there are two ways to send letters.

  • using the web service (AmazonSimpleEmailServiceClient)
  • using SMTP

The user that was created was for smtp, ses-smtp-user.some_number. You use these credentials to call the web service.

My suggestion is to create a normal user (not on the SES screen) and assign SES permissions. Note that newly created credentials will no longer work with SMTP.

If you need credentials that work with both SMTP and the web service, you can read about it: http://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html#smtp -credentials-convert

+1
source

All Articles