.Vue-email is encouraged through react-email, it enables us make layouts using the vue structure, along with components that help us develop templates quickly and also quick.To begin utilizing vue-email in any kind of vue task, you simply require to put in the plan:.With NPM:.$ npm install vue-email.With Yarn:.$ anecdote add vue-email.Along with PNPM:.$ pnpm put in vue-email.Producing email template.Generate a brand-new email theme in anywhere you would like to have your design templates, for this case, our experts may produce a design template file, along with a theme called welcome.vue.src/templates/welcome. vue.
label, invited to vue-email.A Vue component library for property receptive emails.Scenery on GitHub.Delighted coding!David Arenas.
Leaving the layouts.Our experts may use the leave feature, it acquires 2 params, the initial one is the design template to leave, as well as the second the params to be utilized for the theme, and then pass the outcome theme in the body of demand.Passing the design template in the body system, offer our team the odds of providing using any kind of hosting server, convey, fastify, nuxt in SSR, etc src/pages/index. vue.Send out e-mail with nodemailer.Dispatched email.
Deliver e-mail.In this example i making use of nuxt v3 since it enables us to prepare api inside personal venture, and describe a number of api options.Listed here our experts just extract the design template of the request body, and deliver the email passing the theme in the sendMail functionality of the nodemailer bundle.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export nonpayment defineEventHandler( async (occasion) => const body = await readBody( event).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( multitude: process.env.HOST ).const alternatives = coming from: 'you@example.com',.to: 'user@gmail.com',.target: 'hi there planet',.html: body.template,..wait for transporter.sendMail( choices). ).If you are actually certainly not using the server in nuxt, you may quickly apply on any sort of platform as an example using convey:.bring show coming from 'express'.bring in nodemailer coming from 'nodemailer'.const app = express().app.use( express.json()).app.post('/ api/send-email', async (req, res) => const design template = req.body.const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.protected: incorrect,.auth: individual: testAccount.user,.elapsed: testAccount.pass,.,. ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.target: 'hey there globe',.html: theme,..await transporter.sendMail( options).profit res.json( message: "Email sent out" ). ).app.listen( 3001 ).Paperwork.Receive the full paperwork [right here] ().Parts.You can easily observe the elements, listed below:.Assimilations.E-mails built with vue-email may be exchanged HTML or even.clear text, and also sent making use of any e-mail provider. You can see.examples listed below:.