gpt4 book ai didi

node.js - NodeMailer - 无法读取未定义的属性 'getSocket'

转载 作者:搜寻专家 更新时间:2023-10-31 22:40:29 24 4
gpt4 key购买 nike

Node :v8.6.0 Node 邮件:v4.6.4

这是我的代码:

  const transport = nodemailer.createTransport({
host: process.env.MAIL_HOST,
port: process.env.MAIL_PORT,
auth: {
user: process.env.MAIL_USER,
pass: process.env.MAIL_PASS
}
});

const generateHTML = (filename, options = {}) => {
const html = pug.renderFile(`${__dirname}/../views/email/${filename}.pug`,
options);
const inlined = juice(html);
return inlined;
}

exports.send = async (options) => {
const html = generateHTML(options.filename, options);
const text = htmlToText.fromString(html);
const mailOptions = {
from: `Site <noreply@domain.com>`,
to: options.user.email,
subject: options.subject,
html,
text
};
const sendMail = P.promisify(transport.sendMail, transport);
return sendMail(mailOptions);
}

当我执行 sendMail 时,我得到了这个失败:类型错误:无法在 sendMail 处读取未定义↵ 的属性“getSocket”(/Users/...../node_modules/nodemailer/lib/mailer/index.js:143:24

我检查了提及行,是这个:

if (typeof this.getSocket === 'function') {
this.transporter.getSocket = this.getSocket;
this.getSocket = false;
}

最佳答案

就我而言,我在尝试 promise 传输时收到此错误。 省略 回调参数,它将 native 返回一个 promise 。无需 promise 。

关于node.js - NodeMailer - 无法读取未定义的属性 'getSocket',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49957300/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com