为什么我不能通过节点上的亚马逊电子邮件发送邮件?

我使用“aws-sdk”:“^ 2.117.0”,我的代码如下所示:

var AWS = require('aws-sdk'); exports.sendAWSMail = function(message, destination){ const ses = new AWS.SES(); // http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#sendEmail-property const sendEmail = ses.sendEmail; var data = { Destination: { ToAddresses: [ "blahblah@gmail.com" ] }, Message: { Body: { Html: { Charset: "UTF-8", Data: "This message body contains HTML formatting. It can, for example, contain links like this one: <a class=\"ulink\" href=\"http://docs.aws.amazon.com/ses/latest/DeveloperGuide\" target=\"_blank\">Amazon SES Developer Guide</a>." }, Text: { Charset: "UTF-8", Data: "This is the message body in text format." } }, Subject: { Charset: "UTF-8", Data: "Test email" } }, Source: "no-reply@frutacor.com.br", } sendEmail(data) } 

但是我得到这个错误:

TypeError:this.makeRequest不是svc函数(匿名函数)(/Users/iagowp/Desktop/trampos/frutacor/node_modules/aws-sdk/lib/service.js:499:23)

我没有在他们的网站上find任何Node示例,但从我在别处看到的(如这里 ),它看起来是正确的。 我究竟做错了什么?

主要的问题是在#5行,添加logging错误和成功请求的callback函数总是一个好主意。

 var AWS = require('aws-sdk'); exports.sendAWSMail = function(message, destination){ const ses = new AWS.SES(); var data = { Destination: { ToAddresses: [ "blahblah@gmail.com" ] }, Message: { Body: { Html: { Charset: "UTF-8", Data: "This message body contains HTML formatting. It can, for example, contain links like this one: <a class=\"ulink\" href=\"http://docs.aws.amazon.com/ses/latest/DeveloperGuide\" target=\"_blank\">Amazon SES Developer Guide</a>." }, Text: { Charset: "UTF-8", Data: "This is the message body in text format." } }, Subject: { Charset: "UTF-8", Data: "Test email" } }, Source: "no-reply@frutacor.com.br", } ses.sendEmail(data, function(err, data) { if (err) console.log(err, err.stack); // an error occurred else console.log(data); // successful response }); }