我正在尝试在我的联系表单中使用 nodemailer 来接收反馈并将它们直接发送到电子邮件。这是下面的表格。
<form method="post" action="/contact">
<label for="name">Name:</label>
<input type="text" name="name" placeholder="Enter Your Name" required><br>
<label for="email">Email:</label>
<input type="email" name="email" placeholder="Enter Your Email" required><br>
<label for="feedback">Feedback:</label>
<textarea name="feedback" placeholder="Enter Feedback Here"></textarea><br>
<input type="submit" name="sumbit" value="Submit">
</form>
这是服务器端请求的样子
app.post('/contact',(req,res)=>{
let transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'user@gmail.com',
password: 'password'
}
});
var mailOptions = {
from: req.body.name + '<' + req.body.email + '>',
to: 'bantspl@gmail.com',
subject: 'Plbants Feedback',
text: req.body.feedback
};
transporter.sendMail(mailOptions,(err,res)=>{
if(err){
console.log(err);
}
else {
}
});
我收到错误Missing credentials for "PLAIN"
。任何帮助表示赞赏,非常感谢。