Unable to send email from Java EC2 server
•
Java
Try to send mail from Amazon EC2 server using java code, but you will receive an exception –
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)
Java result: 1
My credentials are sure I don't know why I can't send email here Do I need to configure / update any settings in the server?
Solution
Your user is not authorized to send email to SES in identity and access management (IAM)
Error 403 reference HTTP code 403 unauthorized
The last mistake tells you what permissions you lack
In addition, your AWS account may not register for simple email service, but I suspect it is a problem
You can add groups to Iam that only allow sendemail operations through the following policies:
{ "Statement": [ { "Action": [ "ses:SendEmail" ],"Effect": "Allow","Resource": [ "*" ] } ] }
Alternatively, you can give it a policy that allows it to perform any action in SES with:
{ "Statement": [ { "Action": [ "ses:*" ],"Resource": [ "*" ] } ] }
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码