nodemailer / smtp-server

Create custom SMTP servers on the fly
Other
846 stars 145 forks source link

onAuth is executed twice when an Error is provided as parameter on the callback #154

Open neilpalima opened 3 years ago

neilpalima commented 3 years ago

Is there a config that will not call the onAuth twice? Is this the expected behavior?

Sample code. console.log was executed twice.

onAuth: async (auth: SMTPServerAuthentication, session: SMTPServerSession, callback: CallbackOnAuthInterface) => {

        console.log("Here");
        callback(new Error('Invalid username or password.'));
}
penguoir commented 3 years ago

I think this depends on your server config. If the server has two auth methods then the client will retry authentication with each method. The default for the server authentication methods is ["PLAIN", "LOGIN"] so that's why you're seeing two console.logs.