2017-06-09 18 views
1

私は[email protected]メールアドレスからメールを送信しようとしているが、私は、次のエラーが発生しますを使用してメールを送信しますSESコンソールでステータスと私は[email protected]メールアドレスに以下のIdentity Policyを添付している:私は、次のNodeJSコードを実行するとJavaScriptがAWS SES

{ 
    "Version": "2008-10-17", 
    "Statement": [ 
    { 
     "Sid": "stmt1496992141256", 
     "Effect": "Allow", 
     "Principal": { 
      "AWS": "arn:aws:iam::xxxxxxxxxxxxxxx:root" 
     }, 
     "Action": [ 
      "ses:SendEmail", 
      "ses:SendRawEmail" 
     ], 
     "Resource": "arn:aws:ses:us-west-2:xxxxxxxxxxxxxxx:identity/[email protected]" 
    } 
    ] 
} 

はまだ、私は上記のエラーが表示されます。

Mail.send = function(email, cb) { 
    var ses_mail = "From: 'AWS Tutorial Series' <" + email + ">\n"; 
    ses_mail = ses_mail + "To: " + "[email protected]" + "\n"; 
    ses_mail = ses_mail + "Subject: AWS SES Attachment Example\n"; 
    ses_mail = ses_mail + "MIME-Version: 1.0\n"; 
    ses_mail = ses_mail + "Content-Type: multipart/mixed; boundary=\"NextPart\"\n\n"; 
    ses_mail = ses_mail + "--NextPart\n"; 
    ses_mail = ses_mail + "Content-Type: text/html; charset=us-ascii\n\n"; 
    ses_mail = ses_mail + "This is the body of the email.\n\n"; 
    ses_mail = ses_mail + "--NextPart\n"; 
    ses_mail = ses_mail + "Content-Type: text/plain;\n"; 
    ses_mail = ses_mail + "Content-Disposition: attachment; filename=\"attachment.txt\"\n\n"; 
    ses_mail = ses_mail + "AWS Tutorial Series - Really cool file attachment!" + "\n\n"; 
    ses_mail = ses_mail + "--NextPart--"; 

    var params = { 
     RawMessage: { /* required */ 
      Data: new Buffer(ses_mail) /* required */ 
     }, 
     Destinations: [ 
      email 
     ], 
     FromArn: '[email protected]', 
     ReturnPathArn: '[email protected]', 
     Source: '[email protected]', 
     SourceArn: '[email protected]' 
    }; 

    ses.sendRawEmail(params, function(err, data) { 
     if (err) return cb(err); 
     else return cb(null, data); 
    }); 
}; 

AWSのドキュメント:http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html

答えて

3

ARN in AWS spaceは全体のリソース名を意味しています。これには、以下の有効な形式が含まれます。

arn:partition:service:region:account-id:resource 
arn:partition:service:region:account-id:resourcetype/resource 
arn:partition:service:region:account-id:resourcetype:resource 

その他のものは無効です。したがって、あなたの

FromArn: '[email protected]', 

は次のようになります。

FromArn: 'arn:aws:ses:us-west-2:xxxxxxxxxxxxxxx:identity/[email protected]', 
+0

感謝。これは間違いなく私が得ていたエラーを解決しました。その後、エラーはありませんでしたが、まだメールを受信して​​いませんでした。私は両方の電子メールアドレス(送信者と受信者)に「アイデンティティポリシー」を追加する必要があることを理解しました。 Amazonは当初、あなたのアカウントのAWSアカウントを「サンドボックス」モードにして、確認されていないメールにメールを送ることを禁止しているようだ。 'sandbox'モードが解除されるまでは、SESを使用できるようにするために' Identity Policy'が添付されている検証済みの電子メール間でのみ電子メールを送信できます。 – SuperVeetz