Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mail transporter verification #1153

Merged
merged 2 commits into from
Apr 27, 2024
Merged

Conversation

SimonRosenau
Copy link
Contributor

In case of json transporters, or any transporter which does not implement the verify function, the Mailer class inside nodemailer overwrites it with a generic non-async function, which just returns false. This leads to the following error:

2024-04-03 23:25:19 TypeError: transporter.verify(...).then is not a function
2024-04-03 23:25:19     at MailerService.verifyTransporter (/app/node_modules/@nestjs-modules/mailer/dist/mailer.service.js:67:14)
2024-04-03 23:25:19     at new MailerService (/app/node_modules/@nestjs-modules/mailer/dist/mailer.service.js:60:18)
2024-04-03 23:25:19     at Injector.instantiateClass (/app/node_modules/@nestjs/core/injector/injector.js:365:19)
2024-04-03 23:25:19     at callback (/app/node_modules/@nestjs/core/injector/injector.js:65:45)
2024-04-03 23:25:19     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2024-04-03 23:25:19     at async Injector.resolveConstructorParams (/app/node_modules/@nestjs/core/injector/injector.js:144:24)
2024-04-03 23:25:19     at async Injector.loadInstance (/app/node_modules/@nestjs/core/injector/injector.js:70:13)
2024-04-03 23:25:19     at async Injector.loadProvider (/app/node_modules/@nestjs/core/injector/injector.js:97:9)
2024-04-03 23:25:19     at async /app/node_modules/@nestjs/core/injector/instance-loader.js:56:13
2024-04-03 23:25:19     at async Promise.all (index 4)

By wrapping the call to transporter.verify() inside Promise.resolve we can safely proceed with the existing flow.

See nodemailer source here: https://github.com/nodemailer/nodemailer/blob/fa63b52d8a03da49a60c00b6c073a0d77aeababb/lib/mailer/index.js#L95-L115

@SimonRosenau SimonRosenau requested a review from Clashsoft April 27, 2024 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants