.Vue-email is actually encouraged by react-email, it permits our team develop layouts using the vue structure, along with elements that aid our company construct layouts easily and quickly.To begin making use of vue-email in any sort of vue venture, you just require to put in the deal:.With NPM:.$ npm install vue-email.Along with Yarn:.$ yarn incorporate vue-email.With PNPM:.$ pnpm put up vue-email.Making e-mail theme.Produce a brand-new e-mail layout in wherever you desire to possess your templates, for this instance, our experts can make a layout folder, with a design template phoned welcome.vue.src/templates/welcome. vue.
label, appreciated to vue-email.A Vue element collection for property receptive e-mails.Perspective on GitHub.Pleased coding!David Arenas.
Leaving the templates.We can easily utilize the provide functionality, it receives pair of params, the initial one is actually the design template to provide, and also the second the params to be made use of for the layout, and afterwards pass the result design template in the physical body of demand.Passing the design template in the body, give our team the chance of leaving using any sort of hosting server, reveal, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver email along with nodemailer.Posted e-mail.
Send e-mail.Within this example i using nuxt v3 due to the fact that it allows our team to prepare api inside personal project, and also define a number of api routes.Below our company just draw out the template of the request physical body, as well as deliver the email passing the theme in the sendMail feature of the nodemailer deal.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export nonpayment defineEventHandler( async (event) => const body system = wait for readBody( activity).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hey there planet',.html: body.template,..wait for transporter.sendMail( alternatives). ).If you are actually certainly not making use of the web server in nuxt, you can easily apply on any type of platform for instance making use of convey:.import show from 'show'.import nodemailer coming from 'nodemailer'.const application = share().app.use( express.json()).app.post('/ api/send-email', async (req, res) => const theme = req.body.const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( bunch: process.env.HOST ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'greetings world',.html: layout,..await transporter.sendMail( options).profit res.json( message: "Email sent" ). ).app.listen( 3001 ).Documentation.Get the full paperwork [below] ().Elements.You may observe the elements, listed here:.Combinations.Emails constructed with vue-email may be converted into HTML or even.clear text, as well as delivered using any type of e-mail provider. You can easily find.instances here:.