2017-12-25 9 views
0

내 웹 사이트에서 amazon ses를 사용하여 내 웹 사이트를 통해 이메일을 보내려고합니다. 내 응용 프로그램은 nodejs를 사용하여 개발되었으며 nodemail & nodemailer-ses-transport를 사용하여 메일을 전송합니다. 하지만 다음과 같은 오류가 발생합니다. AWS 콘솔에서 IAM에서Amazon SES 메일이 nodemailer를 사용하여 전송되지 않음

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


    var mailOptions = { 
     "from": "Shajao Customer Service<[email protected]>", 
     "to": to, 
     "subject": subject, 
     "text": text, 
     "html": html 
    }; 

    transporter.sendMail(mailOptions, cb); 

만든 사용자를 내 액세스 키 ID와 비밀 ID를 추가 : 다음과 같이

{ 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 } 

내 코드입니다. 하지만 여전히 일하는 것은 아닙니다. `SES를 추가하는 방법을 잘 : SendRawEmail \ '

답변

0

당신은 IAM에서 사용자에 대한 정책이나 역할을 넣어해야합니다 (? shajao.email)

{ 
    "Version": "2012-10-17", 
    "Statement": [ 
    { 
     "Effect": "Allow", 
     "Action": ["ses:SendEmail", "ses:SendRawEmail"], 
     "Resource":"*" 
    } 
    ] 
} 

IAM을 - -> 사용자> 사용자를 -> 인라인 정책 추가