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

delay first email message

bacloud23 opened this issue · comments

commented

I'm impressed by the capability to cluster sending messages with different transports. Also impressed with the many options available.

I have a website where I'm trying to offer private user messaging using email providers. My website email would act like a man in the middle, this is the scenario:

userA --> admin --> userB

I have a suggestion:

Can I set a time laps for the first message to be send ? It's uncommon to delay email sending, but by this, I just don't want to give a real-time feeling when I set up a channel for two users of my site, when they start messaging. Also to lower the messaging traffic on my admin emails.

Of course I can set a delay function with native JS, but I like the queue functionality (this library) to ensure the message is being sent by server on behalf of other users because it assures availability and also would help keep admin emails indistinguishable (maybe dozens or hundreds).

Many thanks !

Hello @bacloud22 ,

I'm really sorry I've missed your message.
Yes, this is possible for the long time out of the box, just use sendAt option passed along with other option into .sendMail({}) method:

mailQueue.sendMail({
  to: 'user@gmail.com',
  sendAt: new Date(Date.now() + (1000 * 60 * 60 * 4)), // <-- send in 4 hours from now
  subject: 'You\'ve got an email!',
  text: 'Plain text message',
  html: '<h1>HTML</h1><p>Styled message</p>'
});

Thank you for the kind words and I hope this will solve your question.
Feel free to close it in case if the issue is solved on your end.

Thanks @dr-dimitru !!!
I will be back with results later (if anything raises)!