Nodemailer发送包含MySQL数据库信息的电子邮件

时间:2019-11-21 06:43:03

标签: mysql nodemailer

我正在尝试使用Nodemailer进行密码恢复。基本上,用户将在HTML表单中输入电子邮件地址,并且将使用Nodemailer发送电子邮件。该电子邮件将包含来自MySQL数据库的密码。我的问题是,密码显示为“ undefined”。

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'
            };

电子邮件中密码的输出显示为“未定义”。我一直在尝试不同的尝试,但无济于事。有人可以帮我做错什么吗?

0 个答案:

没有答案