Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually encouraged through react-email, it allows us make templates using the vue platform, along with parts that aid our team develop layouts easily and quickly.To begin utilizing vue-email in any sort of vue venture, you just require to put up the package:.Along with NPM:.$ npm put in vue-email.Along with Anecdote:.$ yarn add vue-email.Along with PNPM:.$ pnpm put in vue-email.Making email theme.Generate a brand-new e-mail template in wherever you wish to possess your layouts, for this case, our company can easily generate a layout folder, with a template called welcome.vue.src/templates/welcome. vue.

name, invited to vue-email.A Vue element collection for building reactive e-mails.View on GitHub.Satisfied coding!David Arenas.
Rendering the layouts.Our team can easily utilize the make function, it receives two params, the 1st one is actually the template to provide, and the second the params to be utilized for the layout, and afterwards pass the outcome theme in the body of request.Passing the template in the body system, give our company the possibility of rendering utilizing any kind of hosting server, show, fastify, nuxt in SSR, and so on src/pages/index. vue.Deliver email with nodemailer.Provided email.
Deliver email.Within this instance i using nuxt v3 because it permits us to set api inside own venture, and describe numerous api routes.Here our experts merely extract the theme of the ask for body, as well as deliver the email passing the layout in the sendMail functionality of the nodemailer bundle.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export default defineEventHandler( async (celebration) =&gt const physical body = await readBody( celebration).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const options = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'greetings planet',.html: body.template,..await transporter.sendMail( choices). ).If you are certainly not making use of the web server in nuxt, you may quickly carry out on any kind of framework as an example using express:.import show from 'show'.bring in nodemailer coming from 'nodemailer'.const app = convey().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const template = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( host: process.env.HOST ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.target: 'hi there planet',.html: theme,..wait for transporter.sendMail( alternatives).return res.json( message: "Email sent out" ). ).app.listen( 3001 ).Paperwork.Acquire the full documents [right here] ().Components.You may observe the elements, listed below:.Assimilations.E-mails built along with vue-email may be converted into HTML or even.plain text, as well as sent out making use of any type of email specialist. You may view.examples right here:.