.Vue-email is actually inspired by react-email, it permits us produce design templates making use of the vue structure, along with parts that aid us construct templates easily as well as quickly.To begin utilizing vue-email in any type of vue job, you merely require to mount the deal:.Along with NPM:.$ npm mount vue-email.Along with Anecdote:.$ anecdote include vue-email.With PNPM:.$ pnpm set up vue-email.Creating e-mail layout.Generate a brand new email template in everywhere you desire to possess your layouts, for this situation, our team may produce a design template file, along with a design template contacted welcome.vue.src/templates/welcome. vue.
name, appreciated to vue-email.A Vue component public library for building reactive emails.Scenery on GitHub.Satisfied coding!David Arenas.
Making the templates.We can utilize the render function, it acquires two params, the initial one is the template to make, and the second the params to be made use of for the template, and after that pass the result template in the physical body of ask for.Passing the layout in the physical body, offer our company the chance of leaving utilizing any type of web server, reveal, fastify, nuxt in SSR, and so on src/pages/index. vue.Send e-mail along with nodemailer.Posted email.
Send out e-mail.In this example i making use of nuxt v3 given that it permits our team to prepare api inside personal job, and specify a number of api paths.Below our experts only remove the template of the demand body, as well as send out the email passing the layout in the sendMail feature of the nodemailer plan.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export default defineEventHandler( async (event) => const body system = await readBody( celebration).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.safe: misleading,.auth: user: testAccount.user,.elapsed: testAccount.pass,.,. ).const options = from: 'you@example.com',.to: 'user@gmail.com',.topic: 'greetings globe',.html: body.template,..wait for transporter.sendMail( options). ).If you are not utilizing the web server in nuxt, you may easily implement on any type of structure for instance using express:.bring show from 'convey'.import nodemailer coming from 'nodemailer'.const application = reveal().app.use( express.json()).app.post('/ api/send-email', async (req, res) => const design template = req.body.const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.target: 'hello there world',.html: template,..wait for transporter.sendMail( choices).profit res.json( notification: "Email sent out" ). ).app.listen( 3001 ).Documents.Get the full records [here] ().Components.You may see the parts, listed below:.Assimilations.E-mails developed with vue-email can be exchanged HTML or.plain text, and sent out making use of any kind of email company. You can easily view.examples listed here:.