gpt4 book ai didi

node.js - Nodemailer 在浏览器中显示电子邮件而不是发送它们

转载 作者:行者123 更新时间:2023-12-05 07:32:09 24 4
gpt4 key购买 nike

我正在尝试使用电子邮件模板包,但遇到了问题。一切正常,直到我将路径从静态文件更改为 url。从那时起,每当我尝试发送电子邮件时,它只会在浏览器中显示临时文件,而不是实际发送任何电子邮件。我尝试将其改回,但问题仍然存在。由于这是关于附件的,我假设这是一个 nodemailer 问题,而不是电子邮件模板问题。这是我的代码:

const Email = require("email-templates");
email = new Email({
message: {
from: "pribehytest@seznam.cz"
},
// uncomment below to send emails in development/test env:
// send: true
transport: {
host: "smtp.seznam.cz",
port: 465,
secure: true,
auth: {
user: "mail",
pass: "password"
}
}
})

// this is in a different file
pdf.create(compiledPugInvoice({
// some locals
}), {format: "Letter"}).toFile("emails/newOrder/invoices/invoice" + orderID + ".pdf", (err, result) => {
if(err) next(err);
else{

cloudinary.uploader.upload("emails/newOrder/invoices/invoice" + orderID + ".pdf", (cloudinaryResult) => {
console.log(cloudinaryResult);

// send an email to the client
email
.send({
template: "newOrder",
message: {
to: req.body.email,
attachments: [
{
filename: "faktura.pdf",
path: cloudinaryResult.secure_url
}
]
},
locals: {
// some locals
}
})
.then(() => {
fs.unlink("emails/newOrder/invoices/invoice" + orderID + ".pdf", (err) => {
if(err) next(err);
}))
.catch(console.error);

});

最佳答案

preview : false 添加到您的 email 实例

像这样

email = new Email({
message: {
from: "pribehytest@seznam.cz",
},

send: false, // Change this to true if you want to actually send the email
preview: false, // This will not open the browser

transport: {
host: "smtp.seznam.cz",
port: 465,
secure: true,
auth: {
user: "mail",
pass: "password",
},
},
})

关于node.js - Nodemailer 在浏览器中显示电子邮件而不是发送它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51459327/

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