无法从亚马逊EC2服务器在Java中发送电子邮件 [英] Unable to send email from Amazon EC2 Server in Java

查看:895
本文介绍了无法从亚马逊EC2服务器在Java中发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试发送邮件从亚马逊EC2服务器的Java code,但得到一个异常喜欢 -

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)

Java结果:1

Java Result: 1

我的凭证就可以了,不知道为什么我不能在这里发送电子邮件。 我需要配置/更新服务器上的任何设置?

My credential is ok don't know why I am unable to send email here. will I need to configure/update any setting in server?

推荐答案

您未授权用户的身份和访问管理(IAM)发送电子邮件到SES。

You user is not authorized in Identity and Access Management (IAM) to send email to SES.

错误403指HTTP code 403未经授权。

Error 403 refers to the HTTP code 403 Unauthorized.

在最后的错误告诉你什么权限,你所缺乏的。

The error at the end tells you what permission you are lacking.

ARN:AWS:IAM :: 696355342546:用户/ brandzter无权执行:   SES:SendEmail

arn:aws:iam::696355342546:user/brandzter is not authorized to perform: ses:SendEmail

或者您的AWS账户不得报名参加了简单的电子邮件服务,但我怀疑这就是问题所在。

Alternately your AWS account may not be signed up for the Simple Email Service, but I doubt that is the problem.

您可以添加一组IAM被允许仅仅是sendEmail行动以下策略:

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": [
        "*"
      ]
    }
  ]
}

另外,你可以给它一个政策,允许它执行任何行动SES有:

Alternately you can give it a policy that allows it to execute any action on SES with:

{
  "Statement": [
    {
      "Action": [
        "ses:*"
      ],
      "Effect": "Allow",
      "Resource": [
        "*"
      ]
    }
  ]
}

这篇关于无法从亚马逊EC2服务器在Java中发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆