Sleep

Vue- Email - Vue.js Nourished

.Vue-email is actually encouraged by react-email, it permits our team generate templates making use of the vue framework, with components that help our team create layouts effortlessly as well as swiftly.To begin making use of vue-email in any type of vue task, you merely require to mount the package deal:.Along with NPM:.$ npm install vue-email.Along with Anecdote:.$ yarn add vue-email.Along with PNPM:.$ pnpm set up vue-email.Making email theme.Produce a brand-new e-mail layout in wherever you want to possess your themes, for this instance, we can make a template directory, with a theme gotten in touch with welcome.vue.src/templates/welcome. vue.

name, appreciated to vue-email.A Vue part collection for building receptive e-mails.Viewpoint on GitHub.Happy coding!David Arenas.
Making the design templates.Our experts can make use of the leave function, it obtains pair of params, the first one is actually the theme to render, and the 2nd the params to be utilized for the design template, and then pass the end result template in the physical body of ask for.Passing the design template in the physical body, offer our company the chance of leaving making use of any sort of web server, show, fastify, nuxt in SSR, and so on src/pages/index. vue.Send out email along with nodemailer.Provided email.
Send email.In this instance i making use of nuxt v3 considering that it permits our company to set api inside own venture, as well as describe numerous api courses.Listed here our team simply remove the template of the demand physical body, and also send out the e-mail passing the template in the sendMail function of the nodemailer package deal.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export default defineEventHandler( async (occasion) =&gt const physical body = wait for readBody( celebration).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.safe: untrue,.auth: consumer: testAccount.user,.pass: testAccount.pass,.,. ).const alternatives = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'greetings globe',.html: body.template,..wait for transporter.sendMail( possibilities). ).If you are actually certainly not utilizing the hosting server in nuxt, you can simply execute on any structure for instance using convey:.import reveal coming from 'express'.import nodemailer from 'nodemailer'.const app = convey().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const design template = req.body.const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hello there world',.html: theme,..await transporter.sendMail( alternatives).profit res.json( notification: "Email sent out" ). ).app.listen( 3001 ).Records.Obtain the full paperwork [here] ().Components.You can observe the elements, listed below:.Combinations.Emails created along with vue-email can be converted into HTML or.plain text, as well as sent out using any email company. You can observe.examples here:.

Articles You Can Be Interested In