简体   繁体   English

AWS SES-Nodemailer-transporter.sendEmail不是函数

[英]AWS SES - Nodemailer - transporter.sendEmail is not a function

const nodemailer = require('nodemailer');
const aws = require('aws-sdk');
aws.config.update({region: 'myRegion');
const senderEmail = process.env.SENDER_EMAIL;
const destinationEmail = process.env.DESTINATION_EMAIL;
const transporter = nodemailer.createTransport({
SES: new aws.SES({
apiVersion: '2010-12-01'
})
});
exports.handler = async (event) => {
 let request = event.body;
 try {
 await this.sendEmail(request);
   return {
  'statusCode': 201,
  'headers': {
    'Access-Control-Allow-Origin': '*'
   }
 };
 } catch (error) {
return {
  'statusCode': 500
 };
  }
  };

exports.sendEmail = async (request) => {
try {
await transporter.sendEmail({
  from: senderEmail,
  to: destinationEmail,
  subject: 'Hello',
  text: 'Hello using SES'
  });
  } catch (error) {
   console.log(error);
   throw error;
   }
   };

I have the following code which gives a error saying 'transporter.Email' is not a function. 我有以下代码,错误提示“ transporter.Email”不是一个函数。 I have the following dependencies specified in my package.json (Some content is stripped but it is a valid JSON) 我在package.json中指定了以下依赖项(某些内容已被剥离,但它是有效的JSON)

  "devDependencies": {
    "aws-sdk": "^2.267.1",
    "chai": "^4.1.2",
    "eslint": "^5.1.0",
    "eslint-config-standard": "^11.0.0",
    "eslint-plugin-import": "^2.13.0",
    "eslint-plugin-node": "^6.0.1",
    "eslint-plugin-promise": "^3.8.0",
    "eslint-plugin-standard": "^3.1.0",
    "hippie-swagger": "^3.2.0",
    "mocha": "^5.1.1",
    "mochawesome": "^3.0.3",
    "sinon": "^6.1.0",
    "swagger-parser": "^5.0.2"
  },
  "dependencies": {
    "axios": "^0.18.0",
    "nodemailer": "^4.6.8",
    "nodemailer-ses-transport": "^1.5.1"
  }

At the first look, it does not look like a permissions issue, so ruling that out. 乍一看,它看起来不像是权限问题,因此请排除在外。 Any pointers to fix it would be of great help. 修复它的任何指针将有很大帮助。

I am using Node.js 8.10 in lambda. 我在lambda中使用Node.js 8.10。

Should be transporter.sendMail 应该是transporter.sendMail

http://nodemailer.com/usage/#sending-mail http://nodemailer.com/usage/#sending-mail

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS SES - 记录SendEmail和SendRawEmail调用(SMTP) - AWS SES - Logging SendEmail & SendRawEmail calls (SMTP) 无法在基于 NodeJS 的 lambda 回调中调用 AWS SES sendEmail 函数 - Unable to call AWS SES sendEmail function in the call back to getSignedUrl in my NodeJS based lambda 如何使用 PHP 中的 sendEmail 函数在 Amazon AWS SES API 中设置“List-Unsubscribe”标头? - How to setup the "List-Unsubscribe" header in Amazon AWS SES API using the sendEmail function in PHP? AWS SES:用户无权对资源执行 ses:SendEmail - AWS SES: User is not authorized to perform ses:SendEmail on resource 使用 Nodemailer 和导入的 AWS SES 发送电子邮件 - Send emails with Nodemailer and AWS SES with imports AWS SES SesClient sendEmail()方法的结果如何处理? - What to do with the result of AWS SES SesClient sendEmail() method? 如何使用 AWS SES sendEmail API 发送 html 邮件 - How to send html mail using AWS SES sendEmail API AWS sam SES sendEmail 导致 InvalidClientTokenId (nodejs/lambda) - AWS sam SES sendEmail results in InvalidClientTokenId (nodejs/lambda) aws ses.sendEmail 从本地工作但不是远程工作 - aws ses.sendEmail working from local but not remote AWS ses sendEmail php sdk 错误 Email 地址未验证 - AWS ses sendEmail php sdk error Email address not verified
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM