Unable to send email from Amazon EC2 Server in Java

后端 未结 2 906
北海茫月
北海茫月 2021-02-20 03:29

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         


        
相关标签:
2条回答
  • 2021-02-20 04:27

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

    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:user/brandzter is not authorized to perform: ses:SendEmail

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

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

    {
      "Statement": [
        {
          "Action": [
            "ses:*"
          ],
          "Effect": "Allow",
          "Resource": [
            "*"
          ]
        }
      ]
    }
    
    0 讨论(0)
  • 2021-02-20 04:35

    In my case i Went to IAm console, choose my user and attach policy AmazonSESFullAccess

    0 讨论(0)
提交回复
热议问题