Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually motivated through react-email, it enables us create themes making use of the vue platform, along with components that aid our team construct design templates easily and also quickly.To start using vue-email in any kind of vue task, you merely need to have to mount the plan:.With NPM:.$ npm set up vue-email.Along with Yarn:.$ anecdote add vue-email.Along with PNPM:.$ pnpm put up vue-email.Making e-mail template.Create a new e-mail design template in wherever you intend to possess your layouts, for this instance, our experts can easily develop a template file, along with a template contacted welcome.vue.src/templates/welcome. vue.

label, appreciated to vue-email.A Vue element public library for property receptive e-mails.View on GitHub.Satisfied coding!David Arenas.
Making the templates.Our company may utilize the provide function, it obtains 2 params, the very first one is the theme to render, and also the 2nd the params to become utilized for the theme, and after that pass the outcome design template in the body of demand.Passing the layout in the physical body, offer our company the odds of rendering making use of any type of hosting server, express, fastify, nuxt in SSR, and so on src/pages/index. vue.Deliver email along with nodemailer.Provided email.
Deliver e-mail.In this example i using nuxt v3 considering that it enables us to prepare api inside personal venture, and describe various api paths.Here our company simply draw out the layout of the request body system, and send out the email passing the theme in the sendMail function of the nodemailer bundle.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export nonpayment defineEventHandler( async (occasion) =&gt const body = await readBody( activity).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( lot: process.env.HOST ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.target: 'hello there planet',.html: body.template,..await transporter.sendMail( alternatives). ).If you are actually certainly not using the server in nuxt, you may simply execute on any type of platform for instance utilizing express:.bring share coming from 'express'.bring in nodemailer from 'nodemailer'.const app = convey().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const layout = req.body.const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'greetings world',.html: theme,..wait for transporter.sendMail( options).gain res.json( notification: "Email sent out" ). ).app.listen( 3001 ).Documents.Obtain the complete paperwork [right here] ().Elements.You can see the parts, listed here:.Combinations.Emails developed with vue-email could be converted into HTML or even.plain text, as well as delivered using any sort of email service provider. You can easily see.examples below:.