Sleep

Vue- Email - Vue.js Nourished

.Vue-email is motivated by react-email, it permits our company create templates using the vue structure, with elements that help us construct design templates conveniently and also fast.To start making use of vue-email in any vue project, you simply require to put up the bundle:.With NPM:.$ npm set up vue-email.Along with Yarn:.$ yarn add vue-email.Along with PNPM:.$ pnpm mount vue-email.Making e-mail template.Develop a brand new e-mail design template in wherever you want to have your themes, for this scenario, our experts can generate a template folder, along with a layout contacted welcome.vue.src/templates/welcome. vue.

label, appreciated to vue-email.A Vue part library for property receptive e-mails.Perspective on GitHub.Happy coding!David Arenas.
Rendering the layouts.We may utilize the leave function, it receives two params, the first one is the template to provide, as well as the 2nd the params to become made use of for the design template, and after that pass the result template in the body system of request.Passing the template in the body, offer our team the opportunity of providing utilizing any hosting server, share, fastify, nuxt in SSR, and so on src/pages/index. vue.Send out email with nodemailer.Mailed e-mail.
Send e-mail.In this particular instance i utilizing nuxt v3 since it permits our team to set api inside personal job, as well as describe various api routes.Below our experts simply remove the design template of the demand body, and send the email passing the theme in the sendMail function of the nodemailer bundle.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export default defineEventHandler( async (celebration) =&gt const body = await readBody( event).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( host: process.env.HOST ).const alternatives = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hi planet',.html: body.template,..await transporter.sendMail( possibilities). ).If you are actually certainly not utilizing the hosting server in nuxt, you can simply apply on any type of framework for instance using reveal:.bring express from 'reveal'.import nodemailer from 'nodemailer'.const app = share().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const template = req.body.const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( bunch: process.env.HOST ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'greetings globe',.html: theme,..wait for transporter.sendMail( choices).return res.json( information: "Email delivered" ). ).app.listen( 3001 ).Documentation.Obtain the total records [here] ().Parts.You can find the components, listed below:.Assimilations.E-mails created with vue-email could be converted into HTML or even.plain text, as well as delivered making use of any type of email service provider. You can observe.examples listed here:.