【问题标题】:Nodemailer SES TRANSPORT Error: TypeError: this.ses.sendRawEmail is not a functionNodemailer SES TRANSPORT 错误:TypeError:this.ses.sendRawEmail 不是函数
【发布时间】:2021-12-24 16:04:36
【问题描述】:

我正在尝试在 nodemailer 的帮助下配置 AWS SES。
所以我关注documentation
这是他们提供并且我测试过的代码:

let nodemailer = require("nodemailer");
let aws = require("@aws-sdk/client-ses");

const ses = new aws.SES({
  apiVersion: "2010-12-01",
  region: "us-west-2",
});

// create Nodemailer SES transporter
let transporter = nodemailer.createTransport({
  SES: { ses, aws },
});

// send some mail
transporter.sendMail(
  {
    // These are obviously not the actual emails I am using
    from: "configured_aws_email",
    to: "recipient_email",
    subject: "Message",
    text: "I hope this message gets sent!",
    ses: {
      // optional extra arguments for SendRawEmail
      Tags: [
        {
          Name: "tag_name",
          Value: "tag_value",
        },
      ],
    },
  },
  (err, info) => {
    console.log(
      "???? ~ file: transactional-email-confiig.js ~ line 36 ~ err",
      err
    );
    console.log(
      "???? ~ file: transactional-email-confiig.js ~ line 41 ~ info.envelope",
      info.envelope
    );
    console.log(
      "???? ~ file: transactional-email-confiig.js ~ line 43 ~ info.messageId",
      info.messageId
    );
  }
);

这些是我安装的所需打包的版本:

package.json

"@aws-sdk/client-ses": "^3.40.0",
"aws-sdk": "^2.1026.0",

我在 .env 文件中配置了 AWS 密钥:

.env

AWS_ACCESS_KEY_ID=***************
AWS_SECRET_ACCESS_KEY=*************

这是节点版本:

节点-v

v15.8.0

并且我使用的 AWS SES 电子邮件地址已经过验证:

但是,我不断收到此错误:

node_modules/nodemailer/lib/ses-transport/index.js:242
                this.ses.sendRawEmail(sesMessage, (err, data) => {
                         ^

TypeError: this.ses.sendRawEmail is not a function

【问题讨论】:

    标签: javascript node.js amazon-web-services nodemailer amazon-ses


    【解决方案1】:

    对于那些使用import 而不是require 的用户,请检查您是否使用了这个:

    `从'@aws-sdk/client-ses'导入aws;` `import * as aws from '@aws-sdk/client-ses';`

    here所述。

    【讨论】:

      【解决方案2】:

      看起来@aws-sdk/client-ses 接口没有sendRawEmail 方法。

      尝试安装旧的aws-sdk 包:

      npm i aws-sdk

      改用它

      const nodemailer = require("nodemailer");
      const aws = require("aws-sdk");
      
      const ses = new aws.SES({
        apiVersion: "2010-12-01",
        region: "us-west-2",
      });
      
      // create Nodemailer SES transporter
      const transporter = nodemailer.createTransport({
        SES: { ses, aws },
      });
      

      【讨论】:

        猜你喜欢
        • 2018-07-01
        • 2016-08-02
        • 2016-03-25
        • 1970-01-01
        • 1970-01-01
        • 2013-02-27
        • 2013-01-04
        • 1970-01-01
        • 2020-01-03
        相关资源
        最近更新 更多