Sleep

Vue- Email - Vue.js Feed

.Vue-email is motivated through react-email, it enables our team make design templates making use of the vue framework, with components that aid our team develop themes quickly as well as quickly.To start utilizing vue-email in any kind of vue task, you only need to install the package:.With NPM:.$ npm set up vue-email.Along with Yarn:.$ yarn add vue-email.With PNPM:.$ pnpm put up vue-email.Creating email layout.Develop a brand-new email theme in anywhere you wish to have your design templates, for this scenario, our team may create a layout file, with a template phoned welcome.vue.src/templates/welcome. vue.

name, invited to vue-email.A Vue element collection for building responsive emails.Scenery on GitHub.Happy coding!David Arenas.
Providing the layouts.Our company can use the render functionality, it gets pair of params, the initial one is actually the theme to render, and the second the params to become made use of for the design template, and then pass the result template in the body of ask for.Passing the layout in the body system, provide our team the opportunity of rendering making use of any web server, show, fastify, nuxt in SSR, and so on src/pages/index. vue.Send out email with nodemailer.Mailed e-mail.
Send out e-mail.Within this instance i using nuxt v3 because it permits our company to specify api inside personal task, and specify multiple api paths.Below our company only remove the design template of the demand body, and also deliver the e-mail passing the design template in the sendMail functionality of the nodemailer package deal.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 alternatives = from: 'you@example.com',.to: 'user@gmail.com',.target: 'hi world',.html: body.template,..await transporter.sendMail( options). ).If you are not using the hosting server in nuxt, you may simply carry out on any type of framework for instance making use of convey:.bring express from 'express'.bring in nodemailer coming from 'nodemailer'.const application = express().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const layout = req.body.const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const alternatives = coming from: 'you@example.com',.to: 'user@gmail.com',.target: 'hi globe',.html: template,..await transporter.sendMail( alternatives).yield res.json( message: "Email sent" ). ).app.listen( 3001 ).Paperwork.Receive the total documents [right here] ().Parts.You can easily find the components, listed here:.Combinations.Emails developed along with vue-email may be converted into HTML or even.plain text, and sent out making use of any e-mail service provider. You can easily see.examples listed here:.