未使用nodemailer发送Amazon SES邮件

时间:2017-12-25 10:59:38

标签: amazon-web-services amazon-ses nodemailer

尝试在我的网站上使用amazon ses通过我的网站发送电子邮件。我的应用程序是使用nodejs开发的,并使用nodemail& nodemailer-SES-运输。但是得到以下错误。

{ AccessDenied: User `arn:aws:iam::755682848022:user/shajao.email' is not authorized to perform `ses:SendRawEmail' on resource `arn:aws:ses:us-east-1:755682848022:identity/shajao.com'
    at Request.extractError (/Volumes/Zotac 120GB/6sense/printit/printit-backend/node_modules/aws-sdk/lib/protocol/query.js:47:29)
    at Request.callListeners (/Volumes/Zotac 120GB/6sense/printit/printit-backend/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
    at Request.emit (/Volumes/Zotac 120GB/6sense/printit/printit-backend/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/Volumes/Zotac 120GB/6sense/printit/printit-backend/node_modules/aws-sdk/lib/request.js:683:14)
    at Request.transition (/Volumes/Zotac 120GB/6sense/printit/printit-backend/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/Volumes/Zotac 120GB/6sense/printit/printit-backend/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /Volumes/Zotac 120GB/6sense/printit/printit-backend/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/Volumes/Zotac 120GB/6sense/printit/printit-backend/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/Volumes/Zotac 120GB/6sense/printit/printit-backend/node_modules/aws-sdk/lib/request.js:685:12)
    at Request.callListeners (/Volumes/Zotac 120GB/6sense/printit/printit-backend/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
    at Request.emit (/Volumes/Zotac 120GB/6sense/printit/printit-backend/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/Volumes/Zotac 120GB/6sense/printit/printit-backend/node_modules/aws-sdk/lib/request.js:683:14)
    at Request.transition (/Volumes/Zotac 120GB/6sense/printit/printit-backend/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/Volumes/Zotac 120GB/6sense/printit/printit-backend/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /Volumes/Zotac 120GB/6sense/printit/printit-backend/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/Volumes/Zotac 120GB/6sense/printit/printit-backend/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/Volumes/Zotac 120GB/6sense/printit/printit-backend/node_modules/aws-sdk/lib/request.js:685:12)
    at Request.callListeners (/Volumes/Zotac 120GB/6sense/printit/printit-backend/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
    at callNextListener (/Volumes/Zotac 120GB/6sense/printit/printit-backend/node_modules/aws-sdk/lib/sequential_executor.js:95:12)
    at IncomingMessage.onEnd (/Volumes/Zotac 120GB/6sense/printit/printit-backend/node_modules/aws-sdk/lib/event_listeners.js:269:13)
    at emitNone (events.js:110:20)
    at IncomingMessage.emit (events.js:207:7)
    at endReadableNT (_stream_readable.js:1059:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)
  message: 'User `arn:aws:iam::755682848022:user/shajao.email\' is not authorized to perform `ses:SendRawEmail\' on resource `arn:aws:ses:us-east-1:755682848022:identity/shajao.com\'',
  code: 'AccessDenied',
  time: 2017-12-25T10:49:05.129Z,
  requestId: '39942938-e961-11e7-aa22-07070e500047',
  statusCode: 403,
  retryable: false,
  retryDelay: 32.881228690068795 }

我的代码如下:

var transporter = nodemailer.createTransport(sesTransport({
        accessKeyId: SESCREDENTIALS.accessKeyId,
        secretAccessKey: SESCREDENTIALS.secretAccessKey,
        rateLimit: 5
    }));


    var mailOptions = {
        "from": "Shajao Customer Service<admin@shajao.com>",
        "to": to,
        "subject": subject,
        "text": text,
        "html": html
    };

    transporter.sendMail(mailOptions, cb);

在aws控制台的IAM中创建用户并添加了我的访问密钥ID和密码ID。但仍然没有工作。不知道如何添加`ses:SendRawEmail \&#39;

1 个答案:

答案 0 :(得分:3)

您需要在IAM中为您的用户设置政策或角色:

UIApplication.shared.open

IAM - &gt;用户 - &gt;你的用户(shajao.email?) - &gt;添加内联政策