Unable to send email from Amazon EC2 Server in Java

0 votes

Trying to send mail from Amazon EC2 server with java code but getting an exception like -

Exception in thread "main" Status Code: 403, AWS Request ID: 3e9319ec-bc62-11e1-b2ea-6bde1b4f192c, AWS Error Code: AccessDenied, AWS Error Message: User: arn:aws:iam::696355342546:user/brandzter is not authorized to perform: ses:SendEmail
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:500)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:262)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:166)
at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.invoke(AmazonSimpleEmailServiceClient.java:447)
at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.sendEmail(AmazonSimpleEmailServiceClient.java:242)
at brandzter.util.SESExample.SendMail(SESExample.java:46)
at brandzter.util.SESExample.<init>(SESExample.java:31)
at brandzter.util.SESExample.main(SESExample.java:52)
There is no problem with credentials, so i dont know why i am not able to send a mail and why i am getting this error?
Nov 30, 2018 in AWS by datageek
• 3,000 points
69 views

1 answer to this question.

0 votes

It mostly could be due to two reasons

  1. You user is not authorized in Identity and Access Management (IAM) to send email to SES.
  2. Alternately your AWS account may not be signed up for the Simple Email Service, but I doubt that is the problem.

    You can add a group to IAM that is allowed just the sendEmail action with the following policy:

    {
      "Statement": [
        {
          "Action": [
            "ses:SendEmail"
          ],
          "Effect": "Allow",
          "Resource": [
            "*"
          ]
        }
      ]
    }
answered Nov 30, 2018 by Archana
• 5,480 points

Related Questions In AWS

0 votes
1 answer

How to upload a lib for Tomcat in Amazon EC2?

You need to set the proper privileges ...READ MORE

answered Aug 20, 2018 in AWS by Archana
• 4,090 points
34 views
0 votes
1 answer

Amazon EC2 instance unable to resolve host.

Here is my checklist of things you ...READ MORE

answered Aug 23, 2018 in AWS by Archana
• 4,090 points
349 views
+3 votes
5 answers

How to move files from amazon ec2 to s3 bucket using command line

First Option sm3cmd Use s3cmd s3cmd get s3://AWS_S3_Bucket/dir/file Take a ...READ MORE

answered Aug 29, 2018 in AWS by Priyaj
• 56,160 points
1,506 views
0 votes
1 answer
0 votes
1 answer
–1 vote
1 answer

How to read a csv file stored in Amazon S3 using csv.DictReader

The code would be something like this: import ...READ MORE

answered Oct 25, 2018 in AWS by Archana
• 5,480 points
5,377 views