Node.js   发布时间:2022-04-24  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了node.js – 使用nodemailer发送邮件 – 来自字段的电子邮件不正确大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_696_0@
@H_696_0@
尝试使用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',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

电子邮件现在有效,但来自myemailaddress而不是我在模板上输入电子邮件字段的电子邮件.有任何想法吗

解决方法

Gmail和许多其他电子邮件服务不允许您发送包含各种FROM字段的邮件.
@H_696_0@

大佬总结

以上是大佬教程为你收集整理的node.js – 使用nodemailer发送邮件 – 来自字段的电子邮件不正确全部内容,希望文章能够帮你解决node.js – 使用nodemailer发送邮件 – 来自字段的电子邮件不正确所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:jsnodemailer不正确使用发送字段来自电子邮件邮件
猜你在找的Node.js相关文章
其他相关热搜词更多
phpJavaPython程序员load如何string使用参数jquery开发安装listlinuxiosandroid工具javascriptcap