简体   繁体   English

使用 Nodemailer 和导入的 AWS SES 发送电子邮件

[英]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.

相关问题 为什么 AWS SES 发送的电子邮件不显示? - Why do AWS SES Sent Emails don't show up? 不支持 AWS SES 法兰克福区域 - AWS SES Frankfurt region isn't supported 如何在golang中集成aws sdk ses? - How to integrate aws sdk ses in golang? 在 typeorm 中使用 jest 模拟 AWS SES - Mock AWS SES using jest in typeorm nodemailer 在 Aws Ec2 上的生产环境中导致错误 - nodemailer is causing an error in production environment on Aws Ec2 AWS SES(简单电子邮件服务)记录发送的电子邮件收件人地址 - AWS SES(Simple Email Service) logging sent email recipients address Lambda 功能(Go)无法发送 email 与 SES SMTP - Lambda Function(Go) can't send email with SES SMTP 将存储在 S3 存储桶中的 Amazon SES 电子邮件转换为 MimeMessage 类型 (MimeKit) - Cast Amazon SES emails, stored in S3 buckets, to MimeMessage type (MimeKit) AWS Lambda + S3 + SES+ Gmail 转发:'copyObject() 返回错误:' - AWS Lambda + S3 + SES+ Gmail Forwarding : 'copyObject() returned error:' 如何使用 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?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM