Send Multipe Emails Using Nodemailer And Gmail
I am trying to send an email to multiple recipients ( about 3.000 ). All emails are stored in my DB ( Mongo ). So I make a query that return all the email addresses, and I use asyn
Solution 1:
It is because you are attempting to create a new smtp connection for each email. You need to use SMTP pool. Pooled smtp is mostly useful when you have a large number of messages that you want to send in batches or your provider allows you to only use a small amount of parallel connections.
consttransporter=nodemailer.createTransport(smtpTransport({host:'smtp.gmail.com',port:465,pool:true,//Thisisthefieldyouneedtoaddsecure:true,auth: {
user:senderMail,
pass:senderMailPassword
}
}));
You can close the pool as
transporter.close();
Solution 2:
From Gmail : 421 SMTP Server error: too many concurrent sessions
You may handle your send differently :
wait to close the session between each sending
send by bunch of mail
The best way is to manage to not exceed the limit of 10 session in the same time :)
Post a Comment for "Send Multipe Emails Using Nodemailer And Gmail"