Sleep

Vue- Email - Vue.js Nourished

.Vue-email is motivated by react-email, it allows us create layouts using the vue framework, with components that aid our company develop design templates simply as well as swiftly.To begin using vue-email in any vue job, you just need to install the deal:.With NPM:.$ npm put up vue-email.Along with Yarn:.$ yarn incorporate vue-email.Along with PNPM:.$ pnpm install vue-email.Making email theme.Produce a brand new email design template in no matter where you desire to possess your layouts, for this case, our experts can create a design template folder, along with a theme contacted welcome.vue.src/templates/welcome. vue.

label, invited to vue-email.A Vue element public library for property reactive e-mails.Perspective on GitHub.Happy coding!David Arenas.
Making the layouts.Our company can easily utilize the render functionality, it receives two params, the 1st one is the design template to make, and the 2nd the params to be utilized for the layout, and afterwards pass the outcome template in the physical body of request.Passing the layout in the body, provide us the odds of providing using any kind of server, show, fastify, nuxt in SSR, etc src/pages/index. vue.Send e-mail along with nodemailer.Routed email.
Send out email.In this particular instance i utilizing nuxt v3 since it permits our company to specify api inside own job, and also describe a number of api courses.Listed here we merely remove the template of the ask for physical body, and also send the email passing the layout in the sendMail feature of the nodemailer bundle.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export nonpayment defineEventHandler( async (event) =&gt const physical body = wait for readBody( celebration).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.protected: incorrect,.auth: individual: testAccount.user,.elapsed: testAccount.pass,.,. ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'greetings world',.html: body.template,..wait for transporter.sendMail( options). ).If you are actually certainly not utilizing the server in nuxt, you can conveniently implement on any type of framework for instance utilizing express:.bring convey coming from 'express'.bring in nodemailer coming from 'nodemailer'.const application = express().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const theme = req.body.const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( host: process.env.HOST ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hey there world',.html: layout,..wait for transporter.sendMail( options).gain res.json( message: "Email sent" ). ).app.listen( 3001 ).Records.Get the full documents [listed here] ().Elements.You can observe the components, listed here:.Integrations.E-mails developed with vue-email can be converted into HTML or even.plain text, as well as delivered using any kind of email specialist. You can easily see.examples right here:.