Yesterday, I had the pleasure of teaching a class for my students about sending emails to users. The goal was to create an email—if possible, using Handlebars—then send it to a test email account. Then by clicking the link verify the email on the server side.
Here is the link to what I intended to show: Link to my Home Lab. And here is what we accomplished during the class: Class code.
There were some topics I did not cover in the last class. For example, Handlebars.js.
How simple is this?
import Handlebars from "handlebars";
const template = Handlebars.compile("Name: {{name}}");
console.log(template({ name: "Nils" }));
I use this to build up the email message. Templates are located inside the template folder. At the moment there are two templates: otc and welcome.
Additionally, I did not speak about sending emails using an API key. I also wrote an example with the code. One catch here is that I had to install an additional package, nodemailer-mailgun-transport, which creates the transport for us.
Links
https://handlebarsjs.com/guide/#what-is-handlebars https://www.npmjs.com/package/nodemailer-mailgun-transport https://documentation.mailgun.com/docs/mailgun/quickstart-guide/quickstart/ https://nodemailer.com/smtp/ https://nodemailer.com/about/