adonisjs / mail

AdonisJS Email Provider
MIT License
106 stars 34 forks source link

Mail connection stays open => ace commands don't stop #34

Closed simonedelmann closed 4 years ago

simonedelmann commented 5 years ago

I send mails from an ace command via SMTP. The ace command doesn't close (which is bad because it's intended to run via cron) because this package opens a SMTP connection but never closes it. We need either a Mail.close() command (similar to this) or the connection should be closed by default. I could fix the issue by adding this.transporter.close() within src/Mail/Drivers/Smtp.js, but I think there should be a better solution for this.

Package version

3.0.9

Node.js and npm version

Node 12.2.0 npm 6.9.0

Sample Code (to reproduce the issue)

Just create a fresh package + an ace command, send any mail via smtp from there.

simonedelmann commented 5 years ago

I did manage to close the connection in my command like this:

Mail.connection()._driverInstance.transporter.close()

Maybe you can add a shorthand for this? :)

RomainLanz commented 5 years ago

Hey @simonedelmann! 👋

Feel free to create a PR that add Mail.close(). 👍