.Vue-email is influenced through react-email, it permits us develop themes making use of the vue platform, with parts that assist our company create templates easily and fast.To begin making use of vue-email in any kind of vue task, you only need to have to set up the plan:.Along with NPM:.$ npm install vue-email.With Yarn:.$ yarn incorporate vue-email.With PNPM:.$ pnpm set up vue-email.Generating e-mail design template.Develop a new e-mail theme in any place you want to have your design templates, for this case, our experts can easily produce a theme folder, along with a layout gotten in touch with welcome.vue.src/templates/welcome. vue.
label, welcome to vue-email.A Vue component public library for building receptive emails.View on GitHub.Happy coding!David Arenas.
Providing the design templates.Our company may utilize the provide functionality, it gets 2 params, the very first one is actually the layout to leave, and the second the params to be made use of for the layout, and afterwards pass the outcome template in the body system of request.Passing the layout in the body, provide our team the possibility of rendering making use of any kind of server, express, fastify, nuxt in SSR, and so on src/pages/index. vue.Send out email with nodemailer.Sent e-mail.
Deliver email.In this particular instance i using nuxt v3 given that it enables our team to prepare api inside personal job, and specify multiple api paths.Listed here our experts only remove the design template of the ask for physical body, and send the email passing the theme in the sendMail function of the nodemailer plan.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export nonpayment defineEventHandler( async (activity) => const body system = wait for readBody( celebration).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hi there globe',.html: body.template,..wait for transporter.sendMail( options). ).If you are not using the web server in nuxt, you may effortlessly execute on any kind of framework for example using show:.bring show coming from 'show'.import nodemailer from 'nodemailer'.const app = show().app.use( express.json()).app.post('/ api/send-email', async (req, res) => const design template = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( lot: process.env.HOST ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.topic: 'greetings world',.html: layout,..await transporter.sendMail( possibilities).profit res.json( information: "Email delivered" ). ).app.listen( 3001 ).Information.Get the full documents [here] ().Parts.You may observe the components, listed here:.Assimilations.Emails developed along with vue-email could be converted into HTML or.plain text, as well as delivered utilizing any type of email company. You can easily observe.instances here:.