guileen / node-sendmail

send mail without setting up a SMTP server

Home Page:http://guileen.github.com/node-sendmail

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not able to send application error in email

tejasvinishelar opened this issue · comments

I want send email in Bot framework as a "error notification".
So sending email to myself whenever there is an error in bot application.

Below is the code:
adapter.onTurnError = async (context, boterror) => {
// This check writes out errors to console log

var transporter = nodemailer.createTransport({

host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
user:'*****@gmail.com',
pass: PASSWORD
}
});

var mailOptions = {
from:'*****@gmail.com',
to: '******@gmail.com',
subject: 'Bot Error',
text: boterror
}

transporter.sendMail(mailOptions, function(emailerr, emailinfo) {
if (emailerr) {
    console.log("== Error==",emailerr);
    return true;
} else {
    console.log('Email sent: ' + emailinfo.response)
}

})
// Send a message to the user
await context.sendActivity(Oops. Something went wrong!);
// Clear out state
await conversationState.delete(context);
};

Issue :
Whenever there is an bot error, sendemail method consider it as email error and do not send email and executes If(emailerr) block of sendMail callback function