Skip to content

[fix] Use pooling for connections #469

@Martin-Tabya

Description

@Martin-Tabya

Describe the bug

Node.js version: Happens with all nodeJS versions

OS version: Happens in all environments

Description:

When many sequential emails are send, there is a point at which they start to fail with a Invalid login: 421 .... too manny connections from <IP>.
I'm pretty sure I found the bug and also the solution, have a look at this comment: nodemailer/nodemailer#699 (comment)

There should be an easy to configure way to use pooling for sending out batches. As I understand the code right now, we could pass a custom transport-object to the constructor, but that would still result in nodemailer.createTransport() beeing called every time a new Email is send (by new Email()), which would always recreate the transport-object and so circumvent the pooling.

An easy usePooling option would be lovely, also it might make sense to store the original passed config.transport object in a static field. This way it doesn't get re-created on every single email-send.

This fix should be pretty easy and traight forwarded and it would help a lot of users I think :)

Can you find the time for that? Or is that at least something you would agree is a useful change?

Code to reproduce

Just sending multiple mails via new Email() causes the problem.

The amunt of emails at which the problem occurs seems to be related to the environment and node-version etc. In our case it's around 40-50.

Checklist

  • I have searched through GitHub issues for similar issues.
  • I have completely read through the README and documentation.
  • I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions