大佬教程收集整理的这篇文章主要介绍了node.js – 使用nodemailer发送邮件 – 来自字段的电子邮件不正确,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
// 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
以上是大佬教程为你收集整理的node.js – 使用nodemailer发送邮件 – 来自字段的电子邮件不正确全部内容,希望文章能够帮你解决node.js – 使用nodemailer发送邮件 – 来自字段的电子邮件不正确所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。