Sleep

Vue- Email - Vue.js Feed

.Vue-email is actually motivated by react-email, it permits us generate design templates utilizing the vue platform, with elements that help us create themes simply and fast.To start using vue-email in any kind of vue project, you simply need to have to put up the deal:.With NPM:.$ npm install vue-email.Along with Anecdote:.$ anecdote incorporate vue-email.Along with PNPM:.$ pnpm put up vue-email.Developing email template.Create a brand-new email theme in anywhere you want to possess your themes, for this scenario, our team can easily generate a theme directory, with a layout phoned welcome.vue.src/templates/welcome. vue.

name, invited to vue-email.A Vue part library for property reactive emails.View on GitHub.Pleased coding!David Arenas.
Providing the templates.Our team can make use of the leave function, it gets pair of params, the first one is actually the design template to render, and also the 2nd the params to be made use of for the design template, and afterwards pass the end result layout in the body of demand.Passing the theme in the physical body, provide our company the odds of leaving using any kind of web server, reveal, fastify, nuxt in SSR, and so on src/pages/index. vue.Send email along with nodemailer.Routed email.
Send email.In this particular example i utilizing nuxt v3 considering that it permits our company to set api inside own task, and also define several api options.Here we simply draw out the template of the request physical body, and send the email passing the design template in the sendMail function of the nodemailer package deal.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export default defineEventHandler( async (celebration) =&gt const physical body = await readBody( occasion).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( lot: process.env.HOST ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hello planet',.html: body.template,..await transporter.sendMail( options). ).If you are actually not making use of the server in nuxt, you may easily apply on any type of platform as an example using express:.import share coming from 'share'.import nodemailer coming from 'nodemailer'.const application = reveal().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const template = req.body.const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.protected: false,.auth: customer: testAccount.user,.pass: testAccount.pass,.,. ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hi globe',.html: design template,..await transporter.sendMail( alternatives).profit res.json( message: "Email sent" ). ).app.listen( 3001 ).Documentation.Get the total documents [here] ().Parts.You may find the components, listed below:.Combinations.Emails created along with vue-email may be converted into HTML or even.clear text, and also delivered utilizing any e-mail company. You can easily see.instances right here:.