Sleep

Vue- Email - Vue.js Nourished

.Vue-email is influenced through react-email, it permits us create design templates utilizing the vue structure, with parts that help our company create design templates quickly and fast.To begin using vue-email in any kind of vue task, you just need to have to mount the deal:.With NPM:.$ npm put up vue-email.With Anecdote:.$ yarn incorporate vue-email.With PNPM:.$ pnpm mount vue-email.Producing email design template.Produce a brand-new email layout in wherever you wish to have your templates, for this instance, we may produce a theme folder, along with a template called welcome.vue.src/templates/welcome. vue.

name, welcome to vue-email.A Vue part collection for property responsive e-mails.Sight on GitHub.Happy coding!David Arenas.
Providing the themes.Our experts can easily make use of the make function, it obtains pair of params, the first one is the layout to render, and also the 2nd the params to be made use of for the theme, and then pass the result template in the body of request.Passing the design template in the physical body, give our company the odds of leaving using any type of web server, share, fastify, nuxt in SSR, and so on src/pages/index. vue.Send out email with nodemailer.Dispatched e-mail.
Send email.In this particular example i utilizing nuxt v3 due to the fact that it permits our company to specify api inside own task, and also specify several api courses.Below we only extract the design template of the demand body, and also send out the email passing the theme in the sendMail functionality of the nodemailer bundle.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (event) =&gt const body system = await readBody( occasion).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( bunch: process.env.HOST ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'greetings planet',.html: body.template,..await transporter.sendMail( options). ).If you are actually not making use of the server in nuxt, you can simply apply on any sort of structure for instance utilizing reveal:.bring reveal from 'reveal'.import nodemailer coming from 'nodemailer'.const application = share().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const template = req.body.const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.safe and secure: incorrect,.auth: individual: testAccount.user,.successfully pass: testAccount.pass,.,. ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.target: 'hello there globe',.html: template,..await transporter.sendMail( options).gain res.json( information: "Email sent out" ). ).app.listen( 3001 ).Records.Receive the complete records [here] ().Components.You can easily find the components, listed below:.Combinations.E-mails built along with vue-email may be exchanged HTML or even.plain text, as well as delivered using any email company. You can easily view.instances listed here:.

Articles You Can Be Interested In