Sleep

Vue- Email - Vue.js Supplied

.Vue-email is motivated by react-email, it allows us develop design templates using the vue structure, along with elements that aid our team create templates conveniently and also swiftly.To start utilizing vue-email in any sort of vue venture, you simply require to set up the package:.Along with NPM:.$ npm put in vue-email.Along with Anecdote:.$ anecdote include vue-email.Along with PNPM:.$ pnpm mount vue-email.Generating email template.Develop a new email layout in any place you wish to possess your themes, for this scenario, our company can easily generate a layout folder, with a design template contacted welcome.vue.src/templates/welcome. vue.

name, welcome to vue-email.A Vue part collection for property receptive e-mails.Perspective on GitHub.Satisfied coding!David Arenas.
Providing the layouts.Our company can easily make use of the leave feature, it receives pair of params, the initial one is actually the design template to render, and the second the params to be used for the layout, and afterwards pass the outcome layout in the body system of request.Passing the theme in the body, give our team the chance of rendering utilizing any web server, express, fastify, nuxt in SSR, etc src/pages/index. vue.Send out e-mail with nodemailer.Sent e-mail.
Send out email.Within this example i utilizing nuxt v3 since it permits our team to prepare api inside own venture, as well as specify several api courses.Listed below our company simply remove the template of the demand body, and also send out the email passing the template in the sendMail function of the nodemailer package.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (activity) =&gt const physical body = wait for readBody( occasion).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( host: process.env.HOST ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hello there planet',.html: body.template,..await transporter.sendMail( options). ).If you are certainly not using the hosting server in nuxt, you may simply apply on any kind of platform for example using share:.bring express from 'convey'.import nodemailer from 'nodemailer'.const application = reveal().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const design template = req.body.const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( lot: process.env.HOST ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hello there world',.html: theme,..await transporter.sendMail( options).yield res.json( information: "Email sent" ). ).app.listen( 3001 ).Records.Obtain the full paperwork [listed here] ().Parts.You can see the components, listed here:.Integrations.Emails built along with vue-email could be exchanged HTML or.plain text, and also sent out making use of any kind of e-mail provider. You can easily see.instances right here:.