bulletproof-nodejs icon indicating copy to clipboard operation
bulletproof-nodejs copied to clipboard

Email client replacement

Open jcruzmontanari opened this issue 3 years ago • 1 comments

Hi, congratulations for this excelent boilerplate!

I want to know how to use another emailClient in dependencyInjector.ts

For instance, if I'm using Sendgrid I can replace the instance and change the DI, but also need to change the methods in MailerService. So how to make an agnostic MailerService?

https://github.com/santiq/bulletproof-nodejs/blob/b3d82c1ef5b8e544b3c6bd2b86e3b19d4613fb31/src/loaders/dependencyInjector.ts#L15

Replace it with:

const sgInstance = sgMail;

And in the MailerService, need to change the client send method.

https://github.com/santiq/bulletproof-nodejs/blob/b3d82c1ef5b8e544b3c6bd2b86e3b19d4613fb31/src/services/mailer.ts#L23

Replace it with (sendgrid api)

this.emailClient.send(msg)

Is this right? Can you think of any other way or idea?

Thanks a lot.

jcruzmontanari avatar Jun 17 '21 14:06 jcruzmontanari

thats all you need unless there's more you want to provide to StartEmailSequence

elemanhillary avatar May 27 '23 21:05 elemanhillary