Sleep

Vue- Email - Vue.js Feed

.Vue-email is inspired through react-email, it permits our company create templates making use of the vue structure, with parts that assist us develop templates conveniently as well as fast.To start using vue-email in any sort of vue project, you only need to have to put up the bundle:.Along with NPM:.$ npm put in vue-email.With Yarn:.$ yarn include vue-email.With PNPM:.$ pnpm install vue-email.Generating email layout.Make a brand new email layout in wherever you would like to have your themes, for this scenario, our company may create a layout file, with a template phoned welcome.vue.src/templates/welcome. vue.

name, appreciated to vue-email.A Vue part collection for property receptive e-mails.View on GitHub.Pleased coding!David Arenas.
Leaving the design templates.We can make use of the render feature, it receives 2 params, the first one is actually the layout to provide, and the 2nd the params to become made use of for the template, and afterwards pass the result template in the body of ask for.Passing the template in the body, offer our company the possibility of rendering making use of any server, share, fastify, nuxt in SSR, etc src/pages/index. vue.Send out email with nodemailer.Routed e-mail.
Send email.Within this instance i making use of nuxt v3 because it allows us to establish api inside own task, as well as determine a number of api courses.Listed here our team just remove the theme of the ask for physical body, and also deliver the email passing the layout in the sendMail feature of the nodemailer package.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (event) =&gt const body = await readBody( occasion).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( host: process.env.HOST ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hi there world',.html: body.template,..wait for transporter.sendMail( choices). ).If you are actually certainly not using the web server in nuxt, you may simply execute on any type of framework as an example utilizing convey:.import show coming from 'express'.import nodemailer from 'nodemailer'.const app = convey().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const layout = req.body.const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.secure: incorrect,.auth: customer: testAccount.user,.pass: testAccount.pass,.,. ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hi world',.html: template,..wait for transporter.sendMail( alternatives).gain res.json( message: "Email sent" ). ).app.listen( 3001 ).Information.Receive the complete records [here] ().Parts.You can view the parts, listed here:.Combinations.Emails created with vue-email can be exchanged HTML or even.plain text, and also sent out utilizing any type of e-mail company. You may see.examples listed here:.