.Vue-email is actually motivated by react-email, it allows our company produce layouts making use of the vue framework, with components that aid us build layouts quickly and also quickly.To start making use of vue-email in any kind of vue task, you just need to have to put in the package:.With NPM:.$ npm put up vue-email.With Yarn:.$ yarn add vue-email.Along with PNPM:.$ pnpm install vue-email.Producing email theme.Create a brand new email design template in any place you want to have your design templates, for this scenario, our team may create a layout directory, with a theme phoned welcome.vue.src/templates/welcome. vue.
name, welcome to vue-email.A Vue component library for building receptive e-mails.Scenery on GitHub.Pleased coding!David Arenas.
Providing the themes.Our company can easily make use of the make function, it gets 2 params, the very first one is the layout to leave, and the 2nd the params to be utilized for the theme, and then pass the outcome template in the physical body of request.Passing the template in the body, provide our company the odds of making utilizing any type of server, share, fastify, nuxt in SSR, and so on src/pages/index. vue.Send out email with nodemailer.Delivered email.
Send e-mail.In this instance i utilizing nuxt v3 because it enables us to prepare api inside very own job, as well as specify numerous api routes.Listed below our team simply draw out the template of the request body, and send out the e-mail passing the layout in the sendMail functionality of the nodemailer bundle.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export default defineEventHandler( async (celebration) => const body = await readBody( celebration).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hey there globe',.html: body.template,..await transporter.sendMail( alternatives). ).If you are actually certainly not utilizing the hosting server in nuxt, you may effortlessly implement on any type of platform for example making use of convey:.bring express from 'express'.bring in nodemailer from 'nodemailer'.const app = express().app.use( express.json()).app.post('/ api/send-email', async (req, res) => const template = req.body.const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hi there planet',.html: theme,..await transporter.sendMail( options).return res.json( information: "Email delivered" ). ).app.listen( 3001 ).Documentation.Receive the complete records [listed here] ().Components.You may observe the parts, listed below:.Assimilations.Emails constructed along with vue-email can be exchanged HTML or even.plain text, and also delivered utilizing any e-mail service provider. You may view.instances listed here:.