尝试使用
Java代码从Amazon EC2服务器发送邮件,但会收到异常 –
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结果:1
我的凭证是确定不知道为什么我无法在这里发送电子邮件.
我需要配置/更新服务器中的任何设置吗?
解决方法
您的用户未在身份和访问管理(IAM)中授权向SES发送电子邮件.
最后的错误告诉你你缺少什么权限.
arn:aws:iam::696355342546:user/brandzter is not authorized to perform:
ses:SendEmail
另外,您的AWS帐户可能不会注册简单电子邮件服务,但我怀疑是问题.
您可以通过以下策略向IAM添加仅允许sendEmail操作允许的组:
{ "Statement": [ { "Action": [ "ses:SendEmail" ],"Effect": "Allow","Resource": [ "*" ] } ] }
或者,你可以给它一个政策,允许它执行任何行动在SES与:
{ "Statement": [ { "Action": [ "ses:*" ],"Resource": [ "*" ] } ] }