Sleep

Vue- Email - Vue.js Feed

.Vue-email is actually inspired by react-email, it allows us produce themes utilizing the vue framework, with components that assist our company develop layouts simply and also quickly.To begin utilizing vue-email in any kind of vue task, you only require to put up the deal:.With NPM:.$ npm set up vue-email.Along with Anecdote:.$ anecdote include vue-email.Along with PNPM:.$ pnpm put up vue-email.Developing email theme.Make a new e-mail design template in anywhere you want to have your themes, for this situation, our team can easily create a layout directory, along with a design template contacted welcome.vue.src/templates/welcome. vue.

name, appreciated to vue-email.A Vue component library for building responsive e-mails.View on GitHub.Delighted coding!David Arenas.
Rendering the design templates.Our team can make use of the provide function, it receives pair of params, the first one is actually the template to render, and the second the params to become used for the template, and after that pass the result theme in the physical body of demand.Passing the layout in the body, provide us the odds of rendering utilizing any sort of hosting server, express, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver e-mail with nodemailer.Shipped email.
Send out email.In this example i utilizing nuxt v3 since it allows our company to prepare api inside personal job, and also describe multiple api courses.Listed here we merely extract the layout of the request body, and deliver the email passing the template in the sendMail feature of the nodemailer package deal.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export default defineEventHandler( async (occasion) =&gt const physical body = await readBody( activity).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hi there globe',.html: body.template,..await transporter.sendMail( choices). ).If you are certainly not utilizing the hosting server in nuxt, you can easily implement on any framework for example utilizing express:.bring reveal from 'show'.bring in nodemailer coming from 'nodemailer'.const app = express().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( lot: process.env.HOST ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.target: 'hey there planet',.html: design template,..await transporter.sendMail( choices).yield res.json( message: "Email sent" ). ).app.listen( 3001 ).Records.Acquire the total paperwork [right here] ().Parts.You can easily find the components, listed below:.Combinations.E-mails built along with vue-email may be exchanged HTML or even.clear text, and also sent out utilizing any sort of e-mail provider. You may observe.examples listed below:.

Articles You Can Be Interested In