.Vue-email is actually influenced by react-email, it enables us make design templates utilizing the vue structure, along with parts that help our team create layouts effortlessly and swiftly.To begin making use of vue-email in any kind of vue venture, you merely need to mount the package:.Along with NPM:.$ npm set up vue-email.With Yarn:.$ yarn include vue-email.With PNPM:.$ pnpm put in vue-email.Producing email layout.Produce a brand-new email layout in no matter where you wish to have your templates, for this situation, our experts can easily produce a design template file, with a theme called welcome.vue.src/templates/welcome. vue.
name, appreciated to vue-email.A Vue element collection for structure reactive e-mails.Scenery on GitHub.Happy coding!David Arenas.
Rendering the templates.Our company can easily utilize the make feature, it obtains 2 params, the 1st one is actually the theme to provide, and the second the params to become made use of for the template, and afterwards pass the outcome theme in the body of demand.Passing the theme in the physical body, give us the opportunity of rendering utilizing any type of web server, convey, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver e-mail along with nodemailer.Placed e-mail.
Send e-mail.Within this example i making use of nuxt v3 due to the fact that it allows us to establish api inside personal job, as well as specify various api options.Here our experts just extract the theme of the request physical body, as well as send the e-mail passing the design template in the sendMail function of the nodemailer plan.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export default defineEventHandler( async (activity) => const physical body = await readBody( occasion).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.safe and secure: false,.auth: customer: testAccount.user,.successfully pass: testAccount.pass,.,. ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.target: 'hello there globe',.html: body.template,..wait for transporter.sendMail( possibilities). ).If you are not utilizing the hosting server in nuxt, you can simply apply on any framework for instance making use of share:.import reveal from 'share'.import nodemailer from 'nodemailer'.const app = convey().app.use( express.json()).app.post('/ api/send-email', async (req, res) => const template = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.target: 'hello there planet',.html: theme,..wait for transporter.sendMail( alternatives).yield res.json( notification: "Email sent" ). ).app.listen( 3001 ).Documents.Obtain the complete information [below] ().Parts.You can find the elements, listed here:.Integrations.Emails created along with vue-email could be converted into HTML or even.plain text, and delivered utilizing any kind of email specialist. You may see.instances here:.