Sleep

Vue- Email - Vue.js Supplied

.Vue-email is inspired through react-email, it enables our company generate layouts making use of the vue structure, with elements that aid our company develop themes easily as well as quickly.To begin making use of vue-email in any vue project, you merely need to have to put up the bundle:.Along with NPM:.$ npm install vue-email.Along with Yarn:.$ anecdote incorporate vue-email.Along with PNPM:.$ pnpm put up vue-email.Creating email theme.Make a brand-new email template in any place you desire to possess your themes, for this instance, our company can develop a layout folder, along with a design template phoned welcome.vue.src/templates/welcome. vue.

name, appreciated to vue-email.A Vue component collection for structure receptive e-mails.Perspective on GitHub.Satisfied coding!David Arenas.
Rendering the templates.Our experts can easily make use of the render functionality, it receives 2 params, the 1st one is actually the design template to make, and the 2nd the params to become made use of for the layout, and then pass the outcome theme in the body system of ask for.Passing the template in the physical body, provide our company the chance of leaving using any sort of server, share, fastify, nuxt in SSR, etc src/pages/index. vue.Send out email along with nodemailer.Dispatched e-mail.
Deliver email.Within this example i utilizing nuxt v3 since it allows our team to prepare api inside personal project, and define several api options.Here our team just extract the design template of the ask for physical body, as well as deliver the email passing the layout in the sendMail feature of the nodemailer package deal.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (celebration) =&gt const physical body = wait for readBody( event).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.target: 'hey there globe',.html: body.template,..await transporter.sendMail( options). ).If you are actually certainly not utilizing the server in nuxt, you may effortlessly execute on any framework for example utilizing express:.bring convey from 'express'.import nodemailer from 'nodemailer'.const application = show().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const layout = req.body.const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.target: 'hello world',.html: design template,..wait for transporter.sendMail( choices).profit res.json( notification: "Email sent" ). ).app.listen( 3001 ).Documentation.Acquire the complete information [listed below] ().Components.You may find the elements, listed below:.Integrations.E-mails developed with vue-email may be converted into HTML or even.clear text, and sent out making use of any kind of e-mail provider. You can easily view.instances here:.

Articles You Can Be Interested In