Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually encouraged through react-email, it enables our team make themes using the vue structure, with components that help our team create themes conveniently and also quickly.To start utilizing vue-email in any vue task, you only need to have to set up the package deal:.With NPM:.$ npm mount vue-email.With Anecdote:.$ anecdote include vue-email.Along with PNPM:.$ pnpm put up vue-email.Creating email layout.Make a brand new e-mail theme in no matter where you wish to have your design templates, for this case, our team can create a template directory, with a template called welcome.vue.src/templates/welcome. vue.

name, appreciated to vue-email.A Vue part library for property receptive emails.Viewpoint on GitHub.Pleased coding!David Arenas.
Making the themes.Our experts can use the make function, it receives 2 params, the initial one is the theme to render, and the second the params to be made use of for the template, and afterwards pass the result layout in the physical body of ask for.Passing the layout in the body, provide our company the chance of making utilizing any sort of server, reveal, fastify, nuxt in SSR, and so on src/pages/index. vue.Send out email with nodemailer.Placed e-mail.
Send out e-mail.Within this instance i utilizing nuxt v3 due to the fact that it allows our company to prepare api inside own task, and also specify multiple api paths.Right here our team simply draw out the layout of the demand body, and also send out the e-mail passing the design template in the sendMail function of the nodemailer deal.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (activity) =&gt const body = wait for readBody( event).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( bunch: process.env.HOST ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hey there planet',.html: body.template,..wait for transporter.sendMail( choices). ).If you are actually certainly not making use of the web server in nuxt, you can simply carry out on any kind of structure as an example using convey:.bring express from 'convey'.bring in nodemailer from 'nodemailer'.const application = convey().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const template = req.body.const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hello world',.html: template,..await transporter.sendMail( choices).return res.json( notification: "Email delivered" ). ).app.listen( 3001 ).Documents.Get the total documentation [listed below] ().Parts.You may view the parts, listed below:.Combinations.Emails created with vue-email can be converted into HTML or even.clear text, as well as sent out utilizing any type of e-mail service provider. You may find.instances listed below:.

Articles You Can Be Interested In