Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 亚马逊SES例外:IAM用户无权执行'SES:SendRawEmail';论资源_Amazon Web Services_Spring Boot_Amazon Ec2_Amazon Elastic Beanstalk_Amazon Ses - Fatal编程技术网

Amazon web services 亚马逊SES例外:IAM用户无权执行'SES:SendRawEmail';论资源

Amazon web services 亚马逊SES例外:IAM用户无权执行'SES:SendRawEmail';论资源,amazon-web-services,spring-boot,amazon-ec2,amazon-elastic-beanstalk,amazon-ses,Amazon Web Services,Spring Boot,Amazon Ec2,Amazon Elastic Beanstalk,Amazon Ses,我是AWS新手,我尝试使用Elastic beanstalk在AWS EC2实例中部署Springboot应用程序。我想利用AWS SES服务向订阅的应用程序用户发送通知 作为其中的一部分,在AWS SDK SES API和IAM凭据的帮助下,我能够使用springboot应用程序发送验证用户电子邮件,但我也想发送未验证用户的电子邮件,因此,我已请求AWS支持团队将我的IAM用户从AWS SES沙箱中解救出来,并增加每天发送电子邮件的限制,AWS支持团队已满足此请求 在将我的IAM用户移出SES

我是AWS新手,我尝试使用Elastic beanstalk在AWS EC2实例中部署Springboot应用程序。我想利用AWS SES服务向订阅的应用程序用户发送通知

作为其中的一部分,在AWS SDK SES API和IAM凭据的帮助下,我能够使用springboot应用程序发送验证用户电子邮件,但我也想发送未验证用户的电子邮件,因此,我已请求AWS支持团队将我的IAM用户从AWS SES沙箱中解救出来,并增加每天发送电子邮件的限制,AWS支持团队已满足此请求

在将我的IAM用户移出SES沙箱后,当我尝试为已验证和未验证的用户发送电子邮件时,我遇到以下错误

org.springframework.mail.MailSendException: Failed messages: com.amazonaws.services.simpleemail.model.AmazonSimpleEmailServiceException:
 User `arn:aws:sts::4***436****2:assumed-role/aws-elasticbeanstalk-ec2-role/i-066edeefc2ed72b10' is not authorized to perform 
 `ses:SendRawEmail' on resource `arn:aws:ses:ap-south-1:4***436****2:identity/ra******ar@gmail.com' 
 (Service: AmazonSimpleEmailService; Status Code: 403; Error Code: AccessDenied; Request ID: 5eeb1f17-a283-4d9f-bca9-ac981ee546c4; 
 Proxy: null); message exception details (1) are:

Failed message 1:
com.amazonaws.services.simpleemail.model.AmazonSimpleEmailServiceException: 
User `arn:aws:sts::4***436****2:assumed-role/aws-elasticbeanstalk-ec2-role/i-066edeefc2ed72b10' is not authorized to perform 
`ses:SendRawEmail' on resource `arn:aws:ses:ap-south-1:4***436****2:identity/ra******ar@gmail.com@gmail.com' 
(Service: AmazonSimpleEmailService; Status Code: 403; Error Code: AccessDenied; Request ID: 5eeb1f17-a283-4d9f-bca9-ac981ee546c4; Proxy: null)
pom.xml:

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-aws</artifactId>
    <version>2.2.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-ses</artifactId>
    <version>1.11.777</version>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-mail</artifactId>
    <version>2.2.6.RELEASE</version>
</dependency>
电子邮件发件人服务类别:

import java.nio.charset.StandardCharsets;

import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import com.ebike.aws.emailutil.Mail;

@Service
public class AWSEmailSenderService {

    private JavaMailSender javaMailSender;

    public AWSEmailSenderService(JavaMailSender javaMailSender) {
        this.javaMailSender = javaMailSender;
    }

    @Async
    public void sendEmail(Mail mail) throws MessagingException {

        try {

            MimeMessage message = getMimeMessage(mail);
            javaMailSender.send(message);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private MimeMessage getMimeMessage(Mail mail) throws MessagingException {

        MimeMessage message = javaMailSender.createMimeMessage();

        MimeMessageHelper helper = new MimeMessageHelper(message, MimeMessageHelper.MULTIPART_MODE_MIXED_RELATED,
                StandardCharsets.UTF_8.name());

        String html = mail.getEmailBody();

        helper.setTo(mail.getTo());
        helper.setText(html, true);
        helper.setSubject(mail.getSubject());
        helper.setFrom(mail.getFrom());
        return message;
    }
}
java有一个获取邮件对象的方法

public Mail getMail() {
    Mail mail = new Mail();
    mail.setFrom(fromEmailID);
    mail.setTo(toEmailId);
    mail.setSubject(subject);
    mail.setEmailBody(emailBody);
    return mail;
}
在获得IAM用户未被授权执行“ses:SendRawEmail”异常后,我尝试添加策略以授予所有可能的权限,但我知道我必须在策略本身中进行修改,但在搜索了一段时间后,我无法理解,我已经经历了这一过程,但没有帮助,或者我无法理解

目前IAM用户有以下AWS策略:

我不知道,以下是适用海关政策的合适地方吗


请帮助我了解如何使用AWS SES为未经验证的电子邮件ID发送电子邮件,并为IAM用户授予所有可能的权限或策略。

此错误与您的IAM用户无关,而是与弹性Beanstalk的AWS-elasticbeanstalk-ec2-role有关


因此,您必须转到IAM角色,找到有问题的角色,并向其添加所需的权限。

此错误与您的IAM用户无关,而是与弹性豆茎的aws-elasticbeanstalk-ec2-role有关


因此,您必须转到IAM角色,找到有问题的角色,并向其添加所需的权限。

感谢您的回答,我已以root用户身份登录,并导航到访问管理中的角色,单击aws-elasticbeanstalk-ec2-role,然后尝试使用AmazonSESFullAccess添加权限边界。这有用吗?。很抱歉打扰你。我是AWS的新手,您的帮助将不胜感激。@Rajeshatwar不是允许的边界。最简单的方法是使用角色窗口上的
附加策略
蓝色按钮,或创建具有权限的内联策略。感谢您的帮助,我已在aws-elasticbeanstalk-ec2-role in roles窗口中创建了内联策略。感谢您的回答,我已以root用户身份登录,并导航到访问管理中的角色,单击aws-elasticbeanstalk-ec2-role,然后尝试使用AmazonSESFullAccess添加权限边界。这有用吗?。很抱歉打扰你。我是AWS的新手,您的帮助将不胜感激。@Rajeshatwar不是允许的边界。最简单的方法是使用角色窗口上的
附加策略
蓝色按钮,或创建具有权限的内联策略。感谢您的帮助,我已在aws-elasticbeanstalk-ec2-role in roles窗口中创建了内联策略。这是工作文件。
public Mail getMail() {
    Mail mail = new Mail();
    mail.setFrom(fromEmailID);
    mail.setTo(toEmailId);
    mail.setSubject(subject);
    mail.setEmailBody(emailBody);
    return mail;
}