veliovgroup / mail-time

📮 Email queue extending NodeMailer with multi SMTP transports and horizontally scaled applications support

Home Page:https://www.npmjs.com/package/mail-time

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Callback function not called

alex-maxime opened this issue · comments

I'm having an issue:

Hello,

I am trying to use mail-time with a cluster configuration

i have my "Micro-service" who is running runs Mail Time as a Server with the type 'server' in option
and my cluster runs Mail Time as a Client with the type 'client' in option.

I would like to log event when e-mail is going but the callback's function when using Mail Time as a Client do not trigger anything

the current fix is to use in both side, the type 'server' in option. but it do not satisfy this :

The main difference between Server and Client type is that the Server handles the queue and sends email. While the Client only adds emails into the queue.

  • Version of mail-time: 1.3.4
  • Version of Node.js : v16.18.1 and NPM : 8.19.2

I have a suggestion:

  • in server mode, add an option onSendMail which is called when callback is empty or when it comes from the client
  • display a warning when a callback is provided in 'clientt' mode (Warning, callback will not be executed in client mode)
new MailTime({
    type: 'server',
     // ... config here
    ...
    onSendMail(error, task, info) {
      nodemailer.getTestMessageUrl(info); // test with Ethereal
    }
});

@alex-maxime 📦 v3.0.0 is out with callbacks removed and new onError and onSent hooks, I hope it will solve your use case

Feel free to close it in case if the issue is solved on your end.

@dr-dimitru thank you, i am no longer working with the company to test it, but i consider it is solved. i wil try this on my new projects