gpt4 book ai didi

node.js - 使用 nodemailer 发送邮件 - 来自字段的电子邮件不正确

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

尝试使用 nodemailer 设置联系表单。这是我的 app.js 中的内容:

// EMail configuration
var smtpTransport = nodemailer.createTransport("SMTP",{
service: "Gmail",
auth: {
user: "myemailaddress",
pass: "xxx"
}
});

// CONTACT FORM
app.get('/contact', function (req, res) {
res.render("contact");
});

app.post('/contact', function (req, res) {
var mailOptions = {
from: req.body.email, // sender address
to: "myemailaddress", // list of receivers
subject: req.body.subject, // Subject line
text: req.body.message, // plaintext body
}
smtpTransport.sendMail(mailOptions, function(error, response){
if(error){
console.log(error);
}else{
console.log("Message sent: " + response.message);
}
smtpTransport.close(); // shut down the connection pool, no more messages
});
res.render("contact", { success: "building web app" });
});

我的 contact.jade 模板如下所示:

form#contact-form(action="/contact", method="POST")
div.span5
p Full name:
input#name(type="text", name="name")
p Email address:
input#email(type="email", name="email")
p Subject:
input#subject(type="text", name="subject")
p Message:
textarea#message(type="text", name="message", rows="5")
p: button(type="submit") Send message

电子邮件现在有效,但来 self 的电子邮件地址,而不是我在模板的电子邮件字段中输入的地址。任何想法

最佳答案

Gmail 和许多其他电子邮件服务不允许您发送带有各种FROM 字段的邮件。

关于node.js - 使用 nodemailer 发送邮件 - 来自字段的电子邮件不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16943961/

24 4 0
文章推荐: html - 在 HTML5 中拖放 Canvas
文章推荐: ios - 滑动时 TableView 单元格高度
文章推荐: swift - 如何从 Swift 文件中提取 API 文档?
文章推荐: css - 如何在
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com