Nodemailer does not Send Mail Text

I can send my mail. But I can not send mail text. Where is problem, I do not know. if I write it like this "mail text ........", it is running. but if I write as variable, mail text does not send.

function sendAlarmMail(emails, alarmMessage) {
    let mailAddresses = emails;
    let mailText = alarmMessage;
    try {
        let testAccount = nodemailer.createTestAccount();

    let transport = nodemailer.createTransport({
        maxConnections: 3,
        pool: true,
        host: 'smtp.gmail.com',
        port: 587,
        secure: false,
        auth: {
            user: 'xxxx@gmail.com',
            pass: 'xxxx'
        }
    });
    
    let message = {
        from: 'xxx@gmail.com',
        to: "xxxx@xxxxx.com",
        subject: 'Yüksek Enerji Kullanım Uyarısı',
        text: `${mailText}`
    }
    transport.sendMail(message, function (err, info) {
        if (err) {
            console.log(err);
            console.log("Mail Gönderilemedi !");
        } else {
            console.log(info);
            console.log("Mail Gönderildi !");
        }
    });
}

sendAlarmMail("mail1, mail2, mail3", "mail texts");

How can I send my text in my mail. help please.

20 thoughts on “Nodemailer does not Send Mail Text”

Leave a Comment