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

Feature request: pass the SMTP code on error #43

Open
michael-ts opened this issue Nov 21, 2017 · 2 comments
Open

Feature request: pass the SMTP code on error #43

michael-ts opened this issue Nov 21, 2017 · 2 comments

Comments

@michael-ts
Copy link

My understanding is that if I call sendmail() and there is a 4XX error code, it is transient and I should retry the call after some delay.

But there is no easy and foolproof way to determine if this is the case.

In sendmail.js:216 I see my callback called as follows:

callback(new Error('SMTP code:' + code + ' msg:' + msg));

This is inconvenient because to determine if there was a 4xx error I have to do some kind of parsing on the string such as via a regex. I can do this, but it is concerning to me because given the total lack of documentation on what the format of the callback parameters are supposed to be, it is conceivable that at some point somebody will decide to reformat the message somehow, breaking my code.

@GreenPioneer
Copy link
Collaborator

@michael-ts what would you propose?

@stormbard
Copy link

stormbard commented Sep 11, 2019

Maybe something like this? This would be a nice to have so that you can better handle the errors on the consumer side.

callback(new Error(
{
   smtpCode: code, 
   smtpResponse: msg, 
   message: 'SMTP code:' + code + ' msg:' + msg"
}));

Or this might be better.

let err = new Error('SMTP code:' + code + ' msg:' + msg);
err.smtpCode = code;
err.smtpResponse = msg;
callback(err);

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

3 participants