Sleep

Vue- Email - Vue.js Nourished

.Vue-email is inspired through react-email, it enables our team generate templates making use of the vue framework, with elements that assist our team construct design templates conveniently and also quick.To start using vue-email in any type of vue task, you simply need to put up the deal:.Along with NPM:.$ npm install vue-email.With Yarn:.$ anecdote incorporate vue-email.With PNPM:.$ pnpm set up vue-email.Generating email layout.Create a new e-mail design template in any place you wish to possess your design templates, for this scenario, our company can easily make a theme file, along with a layout gotten in touch with welcome.vue.src/templates/welcome. vue.

name, invited to vue-email.A Vue element collection for building receptive emails.Viewpoint on GitHub.Happy coding!David Arenas.
Providing the layouts.Our team may use the make functionality, it gets 2 params, the 1st one is the theme to provide, and also the second the params to be made use of for the theme, and afterwards pass the result theme in the physical body of ask for.Passing the layout in the body, offer our company the possibility of rendering utilizing any web server, reveal, fastify, nuxt in SSR, etc src/pages/index. vue.Send out email along with nodemailer.Dispatched e-mail.
Deliver e-mail.In this particular example i using nuxt v3 since it permits us to establish api inside personal venture, and describe multiple api paths.Right here our experts only extract the design template of the ask for body, and send the e-mail passing the design template in the sendMail feature of the nodemailer package.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (event) =&gt const physical body = wait for readBody( activity).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hey there planet',.html: body.template,..wait for transporter.sendMail( choices). ).If you are actually not utilizing the server in nuxt, you may quickly implement on any kind of structure for instance utilizing reveal:.import express coming from 'reveal'.import nodemailer coming from 'nodemailer'.const app = show().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const theme = req.body.const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hi globe',.html: design template,..wait for transporter.sendMail( alternatives).return res.json( information: "Email delivered" ). ).app.listen( 3001 ).Records.Acquire the complete documents [right here] ().Parts.You may find the components, listed here:.Integrations.Emails developed along with vue-email may be converted into HTML or.plain text, and sent using any type of e-mail specialist. You can easily find.instances below:.