mysql - Nodemailer 发送包含 MySQL 数据库信息的电子邮件
问题描述
我正在尝试使用 Nodemailer 进行密码恢复。基本上,用户将在 HTML 表单中输入电子邮件地址,然后使用 Nodemailer 发送电子邮件。该电子邮件将包含来自 MySQL 数据库的密码。我的问题是,密码显示为“未定义”。
app.post('/Forgot_Password_V1', function(request, response) {
var connection = request.app.get('pool');
connection.query('SELECT password FROM accounts WHERE email = ?', [request.body.email], function(error, results, fields) {
https://myaccount.google.com/lesssecureapps?pli=1
{ account: results[0] };
var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: 'user',
pass: 'password'
}
});
//send to the email entered in the form input
var mailOptions = {
from: 'email',
to: request.body.email,
subject: 'Password Request',
text: 'You have requested to recover the password of your account.\n\n' +
request.password + // I tried this
account.password + // I also tried this
'\n End.\n'
};
电子邮件中密码的输出显示“未定义”。我一直在尝试不同的事情无济于事。有人可以帮助我做错什么吗?
解决方案
推荐阅读
- regex - 获取正则表达式以匹配同一模式的多个实例
- java - c++ 是否提供与 java 中的 threadLocal 提供相同支持的任何内置类?
- c - OpenMP 线程,如何正确使用 omp atomic 子句?
- r - 将两个图合并为一个(添加边)R igraph
- node.js - 在 React 中服务不同的页面是如何工作的?
- vue.js - 在 Vue.js 应用程序中正确设置环境变量
- javascript - 量角器承诺调用如何执行函数调用
- proxy - Dante Socks5 代理服务器无法启动
- mysql - MYSQL 限制使用 CREATE、DROP、ALTER
- html - 图片来源不改变图像