Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually encouraged through react-email, it permits us create templates using the vue platform, along with components that aid our team construct layouts quickly as well as quick.To begin using vue-email in any vue project, you simply need to have to put up the package:.With NPM:.$ npm put up vue-email.Along with Yarn:.$ yarn include vue-email.With PNPM:.$ pnpm install vue-email.Creating email design template.Make a brand new email theme in any place you wish to have your layouts, for this scenario, we may generate a template file, with a layout phoned welcome.vue.src/templates/welcome. vue.

title, welcome to vue-email.A Vue component public library for structure reactive e-mails.Viewpoint on GitHub.Satisfied coding!David Arenas.
Rendering the templates.Our team can easily make use of the render function, it obtains 2 params, the first one is the design template to make, and also the 2nd the params to become utilized for the theme, and then pass the end result design template in the body system of request.Passing the design template in the body, offer our team the odds of making making use of any sort of server, reveal, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver email with nodemailer.Directed e-mail.
Send email.Within this example i making use of nuxt v3 because it permits our team to establish api inside own task, as well as determine several api options.Right here our experts merely remove the layout of the ask for body, and deliver the email passing the layout in the sendMail function of the nodemailer deal.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export default defineEventHandler( async (occasion) =&gt const body = wait for readBody( activity).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.safe and secure: incorrect,.auth: individual: testAccount.user,.elapsed: testAccount.pass,.,. ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'greetings globe',.html: body.template,..await transporter.sendMail( alternatives). ).If you are actually not using the server in nuxt, you may effortlessly implement on any structure for instance making use of show:.import reveal coming from 'express'.import nodemailer from 'nodemailer'.const app = share().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const template = req.body.const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.secure: false,.auth: individual: testAccount.user,.pass: testAccount.pass,.,. ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hey there planet',.html: design template,..wait for transporter.sendMail( possibilities).yield res.json( message: "Email sent out" ). ).app.listen( 3001 ).Records.Obtain the full paperwork [listed here] ().Parts.You can easily view the elements, listed below:.Assimilations.Emails created along with vue-email can be converted into HTML or even.plain text, as well as sent out utilizing any type of e-mail provider. You can view.examples below:.

Articles You Can Be Interested In