为什么我无法通过Node上的amazon ses发送电子邮件?

时间:2017-09-18 14:47:54

标签: node.js aws-sdk amazon-ses

我正在使用" 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)

我没有在他们的网站上找到任何Node示例,但是从我在其他地方看到的(例如here),它看起来是正确的。我做错了什么?

1 个答案:

答案 0 :(得分:1)

主要问题在第5行,并且添加回调函数以记录错误和成功请求总是一个好主意。

class Player
{
 ...
 Animation* currentAnimation;
 Animation anim1;
 Animation anim2;
 void Update(bool state);
 ...
 //when class is created, currentAnimation is initialized
}
void Player::Update(bool state)
{
   if(state) currentAnimation = &anim1;
   if(!state) currentAnimation = &anim2;
}