Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

catch error on try nodemailer.createTransport #115

Closed
alvarolm opened this Issue · 1 comment

2 participants

@alvarolm

sorry for my noob'nes )

lets say i have this>

smtpTransport = nodemailer.createTransport("SMTP",{ service: "Gmail", auth: { user: "xxxxx@gmail.com", pass: "xxxxxx" }});

somethimes when I try to auth on gmail smtp services my password could be wrong or anything and with "winston" can see and inspect the error(s) >

logger.on('logging', function (transport, level, msg, meta) {
// GMAIL:AuthError: Invalid login - 535-5.7.1 Username and Password not accepted. - // n=0
if (msg.data) {
    if ((msg.data).search("535-5.7.1")!=-1) {smtpTransport.close(); global.alertm_fatal = true; logger.error('alerta por e-mail cancelada: ' + msg + transport)}
    }
});

thats ok, but i cant find a way to catch if the process is succesful or not, only after happens, I have tried this in various ways >

try {var smtpTransport = nodemailer.createTransport("SMTP",{ service: "Gmail", auth: { user: "xxxxxxx@gmail.com", pass: "xxxxxxxxx" }});} catch (error) { console.log("WTF");}

and just dont work, someone can help me ? :)

it needs a callback !!!?

@andris9
Owner

Hi,

try...catch block does not work with createTransport as createTransport doesn't "do" really anything but storing the credentials for later usage. It is only after trying to send the first e-mail when the connection is actually opened and it is checked if the credentials are actually valid. See return callback for details.

@andris9 andris9 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.