Well some config issue is obvious: 1. either your client has too many open connections, or it sends too many messages on a single open connection, *or* it sends too many messages in a given time frame (some systems also limit # of messages in a time unit). Maybe your app is using a cluster module so you open too many connections from the server, even though you think you limited to X?
So I'd suggest this: 1. instead of sending your messages from your app's other modules, have them stored on a message queue. Can be a database, like Redis, SQL, whatever, or it can be something like RabbitMQ - whatever you already use. Just put them away. 2. Have another subsystem in your app that periodically checks if there are messages on this queue to be sent. This would be my approach regardless of the limits. That's how you decouple your app and the sending of messages. You can deal with multiple app servers, with recovering from crashes, many things. You can even deploy the whole messaging subsystem (sending mails) as a separate node app. Now with the message sending sitting on it's own somewhere, you can do all this fun stuff about rate-limiting your message throughput. You can limit your system to do, e.g. max 1 mail per 5 seconds, or per 1 minute or similar. And to be certain, go to the mail server admins and ask them about the limits, then go bellow those limits. On Thu, Aug 9, 2018 at 3:11 AM sunshine o <[email protected]> wrote: > I have restriction from my company environment to use any other SMTP > server which is why I think I can send 5, not more one time. > > I tried playing with maxConnections etc properties increasing values but > did not help. > > So now, my approach is to live with number 5. But making it send multiple > times. I split the emails data into batches of 5 and then send and > delay/wait. Still first batch of 5 gets delivered, > at next i get error. > > "Too many messages" > "Too many sessions". > > So that means here problem is with my connection close etc. So when next > batch starts, it should be new connection. So I try to initiate the > connection (createTransport()) with each batch. > Please let me know if i am completely wrong approach. > > > On Tuesday, August 7, 2018 at 12:35:22 PM UTC-4, sunshine o wrote: >> >> I have case where I send multiple emails( with different contents and >> subjects), all in array , traversed in a loop to deliver multiple >> receipients. >> >> First I used simple nodemailer and i found more than 5 emails in a row, i >> get errors. >> >> I have input data in a json form where I calculate how many emails and >> what contents will go. So senders list and contents are not static and >> calculated in same code before sending out emails. >> >> so first case, >> 1. Use simple nodemailer. Mail sending part is a promise. Works but not >> more than 5. Each email 's return messages etc can be tracked fine and >> final results can be returned since emails work sequential. >> >> 2. Use nodemailer-smtp-pool to increase number of emails. >> Strange that emails do not work normal. 1 or 2 emails are sent and 3rd >> not. Then if I trigger email code multiple times, within seconds it works >> once or twice with error messages. >> "Mail Command Failed: 421 #4.x.2. too many messages for this session" >> >> Code is: >> >> var smtpPool = require('nodemailer-smtp-pool') >> pooledTr =nodemailer.createTransport( smtpPool{ host: "", secure:false, >> port: 25, maxConnections:25, maxMessaes:50, rateLimit:10...}) >> >> then in a loop for all the emails, >> pooledTr.sendMail(mOptions , (err, callback)=>{....}) >> >> Now, we do not have promise anymore, as we do not want to wait till first >> email send and returns. >> >> Can any one help if I need to use events in pooledtransported, like wait >> till connection is idle to send. Also If I need to add time wait or promise >> till it delivers? >> >> I googled but do not what examples per my scenario. >> > -- > Job board: http://jobs.nodejs.org/ > New group rules: > https://gist.github.com/othiym23/9886289#file-moderation-policy-md > Old group rules: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > --- > You received this message because you are subscribed to a topic in the > Google Groups "nodejs" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/nodejs/fc1xYKNdxFk/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/nodejs/119a2265-c244-4cc7-86ef-f56de0512634%40googlegroups.com > <https://groups.google.com/d/msgid/nodejs/119a2265-c244-4cc7-86ef-f56de0512634%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Zlatko -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/CADu3pbyGzUgJj57U1XKy3eZwc_zeOHuTtUc4ab5ZFpANnHC__Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
