Sleep

Vue- Email - Vue.js Feed

.Vue-email is motivated by react-email, it permits our team make layouts using the vue platform, with elements that assist our team construct layouts quickly and also fast.To begin making use of vue-email in any vue task, you only need to set up the package deal:.With NPM:.$ npm put up vue-email.With Anecdote:.$ anecdote include vue-email.Along with PNPM:.$ pnpm put up vue-email.Producing email design template.Develop a new e-mail layout in wherever you would like to have your templates, for this scenario, our team can create a template directory, along with a design template gotten in touch with welcome.vue.src/templates/welcome. vue.

title, welcome to vue-email.A Vue element library for building receptive emails.Scenery on GitHub.Delighted coding!David Arenas.
Providing the design templates.Our team can easily use the render function, it obtains pair of params, the initial one is actually the theme to provide, and also the second the params to become used for the template, and afterwards pass the outcome layout in the body of demand.Passing the layout in the body system, offer us the opportunity of rendering making use of any type of web server, express, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver email with nodemailer.Delivered e-mail.
Deliver e-mail.In this example i making use of nuxt v3 due to the fact that it permits our company to set api inside personal project, and also specify various api options.Below our team only extract the layout of the request physical body, as well as send out the e-mail passing the template in the sendMail function of the nodemailer bundle.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export nonpayment defineEventHandler( async (activity) =&gt const physical body = await readBody( activity).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( lot: process.env.HOST ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.target: 'greetings world',.html: body.template,..wait for transporter.sendMail( alternatives). ).If you are not making use of the server in nuxt, you can simply apply on any kind of framework for instance using reveal:.bring reveal coming from 'reveal'.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 = from: 'you@example.com',.to: 'user@gmail.com',.target: 'hello world',.html: template,..await transporter.sendMail( alternatives).gain res.json( notification: "Email sent out" ). ).app.listen( 3001 ).Paperwork.Obtain the full documents [below] ().Elements.You may see the elements, listed below:.Combinations.E-mails created along with vue-email could be exchanged HTML or even.clear text, and also delivered making use of any sort of e-mail service provider. You can view.instances here:.