Sleep

Vue- Email - Vue.js Supplied

.Vue-email is inspired by react-email, it allows us develop layouts utilizing the vue structure, with elements that assist our company develop themes quickly and also quick.To start using vue-email in any type of vue task, you only require to set up the bundle:.Along with NPM:.$ npm mount vue-email.With Anecdote:.$ anecdote add vue-email.With PNPM:.$ pnpm install vue-email.Making e-mail theme.Create a brand-new email theme in any place you want to possess your templates, for this situation, our team may make a theme directory, along with a template called welcome.vue.src/templates/welcome. vue.

title, invited to vue-email.A Vue component collection for property receptive emails.View on GitHub.Satisfied coding!David Arenas.
Rendering the design templates.Our company may utilize the provide functionality, it gets two params, the initial one is actually the template to provide, and the second the params to be made use of for the theme, and afterwards pass the outcome design template in the body of ask for.Passing the layout in the body, offer our company the possibility of leaving using any kind of web server, reveal, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver e-mail along with nodemailer.Sent email.
Deliver e-mail.In this particular instance i making use of nuxt v3 because it permits us to specify api inside personal venture, and also describe several api routes.Right here our experts simply remove the design template of the demand body system, and send the e-mail passing the layout in the sendMail function of the nodemailer plan.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (event) =&gt const body = await readBody( activity).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'greetings planet',.html: body.template,..wait for transporter.sendMail( alternatives). ).If you are actually not utilizing the server in nuxt, you may quickly implement on any type of structure for instance utilizing convey:.bring reveal from 'share'.import nodemailer from 'nodemailer'.const app = reveal().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const layout = req.body.const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.safe: incorrect,.auth: customer: testAccount.user,.pass: testAccount.pass,.,. ).const alternatives = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hey there world',.html: design template,..await transporter.sendMail( options).profit res.json( message: "Email sent" ). ).app.listen( 3001 ).Documentation.Obtain the full documentation [listed here] ().Components.You can easily view the elements, listed here:.Combinations.Emails built with vue-email could be converted into HTML or even.plain text, and delivered making use of any type of email company. You can easily view.examples below:.