Sleep

Vue- Email - Vue.js Nourished

.Vue-email is actually inspired through react-email, it allows our team make templates using the vue structure, with parts that help our company create themes conveniently and also swiftly.To start utilizing vue-email in any type of vue venture, you simply need to put in the bundle:.Along with NPM:.$ npm mount vue-email.With Anecdote:.$ anecdote add vue-email.Along with PNPM:.$ pnpm put up vue-email.Developing e-mail design template.Create a brand new e-mail theme in anywhere you desire to possess your layouts, for this scenario, our company can easily make a template folder, along with a layout called welcome.vue.src/templates/welcome. vue.

name, invited to vue-email.A Vue element collection for building reactive e-mails.Sight on GitHub.Delighted coding!David Arenas.
Providing the templates.Our team can make use of the leave feature, it acquires 2 params, the 1st one is the theme to leave, and also the second the params to become utilized for the design template, and afterwards pass the outcome layout in the body of ask for.Passing the template in the body system, provide our company the chance of making utilizing any kind of web server, convey, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver e-mail with nodemailer.Routed e-mail.
Send e-mail.In this particular example i making use of nuxt v3 since it allows our company to establish api inside personal job, and define several api courses.Below our team just extract the theme of the ask for physical body, and send the e-mail passing the layout in the sendMail feature of the nodemailer bundle.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export default defineEventHandler( async (activity) =&gt const physical body = await readBody( occasion).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( multitude: process.env.HOST ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hello planet',.html: body.template,..await transporter.sendMail( alternatives). ).If you are not making use of the web server in nuxt, you may quickly execute on any type of structure for instance utilizing show:.import share from 'share'.import nodemailer coming from 'nodemailer'.const application = convey().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const theme = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hi there globe',.html: template,..wait for transporter.sendMail( choices).yield res.json( notification: "Email delivered" ). ).app.listen( 3001 ).Information.Receive the complete documentation [listed here] ().Elements.You may see the components, listed below:.Combinations.Emails created along with vue-email may be converted into HTML or even.plain text, and also sent utilizing any sort of email service provider. You can easily find.instances listed here:.

Articles You Can Be Interested In