Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catch error on try nodemailer.createTransport #115

Closed
alvarolm opened this issue Oct 29, 2012 · 1 comment
Closed

catch error on try nodemailer.createTransport #115

alvarolm opened this issue Oct 29, 2012 · 1 comment

Comments

@alvarolm
Copy link

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
Copy link
Member

andris9 commented Oct 29, 2012

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 as completed Oct 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants