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,090 points
1,121 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,640 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,170 points
715 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,170 points
5,445 views
+3 votes
6 answers

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

Hey, 3 ways you can do this: To ...READ MORE

answered Oct 9, 2018 in AWS by Omkar
• 69,210 points
19,268 views
0 votes
1 answer

Using Shapely on AWS Lambda with Python 3

For some reason, the pip install of ...READ MORE

answered Oct 8, 2018 in AWS by Priyaj
• 58,090 points
2,597 views
0 votes
1 answer
0 votes
1 answer
+1 vote
2 answers

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,640 points
53,647 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP