guileen / node-sendmail

send mail without setting up a SMTP server
http://guileen.github.com/node-sendmail
MIT License
559 stars 110 forks source link

Not able to send application error in email #62

Closed tejasvinishelar closed 5 years ago

tejasvinishelar commented 5 years ago

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