Sleep

Vue- Email - Vue.js Feed

.Vue-email is actually inspired by react-email, it enables our company develop layouts making use of the vue platform, along with components that help our company construct design templates simply and quickly.To start utilizing vue-email in any sort of vue job, you merely need to have to install the deal:.With NPM:.$ npm set up vue-email.With Yarn:.$ anecdote incorporate vue-email.With PNPM:.$ pnpm install vue-email.Creating e-mail template.Generate a brand-new e-mail layout in wherever you want to have your themes, for this instance, we can easily make a layout directory, along with a theme phoned welcome.vue.src/templates/welcome. vue.

title, welcome to vue-email.A Vue component collection for property reactive emails.Perspective on GitHub.Pleased coding!David Arenas.
Rendering the design templates.Our team may utilize the render feature, it gets two params, the first one is the design template to make, and also the 2nd the params to become used for the design template, and after that pass the result layout in the body system of ask for.Passing the layout in the body system, offer our team the chance of making utilizing any type of web server, reveal, fastify, nuxt in SSR, and so on src/pages/index. vue.Deliver e-mail with nodemailer.Dispatched email.
Deliver e-mail.In this example i utilizing nuxt v3 given that it permits us to set api inside personal job, as well as determine multiple api options.Here we just extract the layout of the request body system, and deliver the email passing the design template in the sendMail feature of the nodemailer deal.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export nonpayment defineEventHandler( async (occasion) =&gt const body = wait for readBody( occasion).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hi world',.html: body.template,..await transporter.sendMail( options). ).If you are not utilizing the web server in nuxt, you may quickly carry out on any platform as an example using show:.import express coming from 'convey'.import nodemailer coming from 'nodemailer'.const app = share().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const design template = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( multitude: process.env.HOST ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hey there world',.html: template,..await transporter.sendMail( alternatives).gain res.json( notification: "Email delivered" ). ).app.listen( 3001 ).Paperwork.Obtain the full paperwork [right here] ().Components.You can easily observe the parts, listed here:.Combinations.Emails developed with vue-email could be converted into HTML or even.clear text, and also delivered using any type of e-mail provider. You may view.examples listed below:.