In this article I will share with you a module that sends mail to customers using MailJet. On my side, I used this module on top of the React/Node/MySQL starter. This starter has been presented to you last week in this article.
Maybe you are wondering... why using Mailjet ? Because it's free until 6000 mails/months and no credit card is required :D
By getting the web starter I was mentioning above, you'll be able to plug this mail system module directly on top of it and have a functional project with an authentication and a mail system in less than 10 minutes.
Note that using the starter is not mandatory, you can also use the module as standalone. The integration won't be as easy as with the starter, but it should still be simple to integrate it in your already created project :)
In this module, we'll use Mailjet service. We can configure mail templates on their website which will be identified by a unique
ID. Those templates can be filled with static content and dynamic content that will change for every mails (pretty usefull to set usernames or callback url on a button).
The backend will call Mailjet API to sends mails giving :
- template ID
- variables (dynamic data)
Create a MailJet account.
Create your mail transactional template and publish it.
IDof your template in a safe place, we'll need it after.
node-mailjetdependency in your backend :
npm install firstname.lastname@example.org
Mailjet API credentials
Set your mailjet API credentials you get from first step into your environments files located here :
./backend/src/environments. If you already forgot your API credentials, you can find them back using this link
mailerfolder of this module in your backend. You can know setup the template
IDfrom your published template into
That's it ! You are now enable to send mail to a specific user, using your pre-defined template a the
MailerService available in your backend :)
I hope this module will help you saving some time while trying to implement a mailing system in your project.
Note that all modules currently available on the React/NestJS/MySQL web starter are listed here. Do not hesitate to ask for a tutorial on another module on this starter in the comment section !
- The platform sharing the starter and it's modules : Fast Modular Project
- "Send mails with MailJet" module open source code available here.
Do not hesitate to pin and like if you appreciated the article ❤️