[英]Send emails with Nodemailer and AWS SES with imports
Although the official Nodemailer documentation explains how to use Nodemailer with AWS SES , the sample code uses require
statements.尽管官方 Nodemailer 文档解释了如何将 Nodemailer 与 AWS SES 结合使用,但示例代码使用了require
语句。
How to do the same with import
statements?如何对import
语句做同样的事情?
Nodemailer can be used with AWS SES with: Nodemailer 可以与 AWS SES 一起使用:
import nodemailer from 'nodemailer'
import * as aws from '@aws-sdk/client-ses'
const ses = new aws.SES({
apiVersion: "2010-12-01",
region: process.env.AWS_REGION,
credentials: {
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
accessKeyId: process.env.AWS_ACCESS_KEY_ID
}
});
const transport = nodemailer.createTransport({
SES: { ses, aws }
});
let info = await transporter.sendMail({
from: '"Fred Foo 👻" <foo@example.com>',
to: "bar@example.com, baz@example.com",
subject: "Hello ✔",
text: "Hello world?",
html: "<p>Hello world?</p>"
});
PS: The trick about the AWS import
was originally posted as a GH comment . PS:关于 AWS import
的技巧最初作为GH 评论发布。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.