Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually motivated by react-email, it permits us create design templates making use of the vue framework, with parts that help our company build themes effortlessly and quickly.To begin utilizing vue-email in any vue project, you merely need to install the plan:.With NPM:.$ npm mount vue-email.Along with Anecdote:.$ yarn incorporate vue-email.Along with PNPM:.$ pnpm mount vue-email.Generating email design template.Generate a new email template in no matter where you want to possess your layouts, for this instance, our experts can generate a template folder, along with a template gotten in touch with welcome.vue.src/templates/welcome. vue.

name, invited to vue-email.A Vue part public library for structure receptive emails.Scenery on GitHub.Happy coding!David Arenas.
Rendering the themes.Our experts can make use of the render function, it acquires pair of params, the first one is the template to render, as well as the second the params to be used for the theme, and then pass the result template in the body of request.Passing the theme in the body system, give us the chance of making using any type of web server, express, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver e-mail along with nodemailer.Provided e-mail.
Deliver e-mail.In this example i utilizing nuxt v3 considering that it enables our company to prepare api inside personal task, and also describe multiple api paths.Listed below our experts just remove the template of the demand physical body, as well as send the email passing the design template in the sendMail function of the nodemailer package deal.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export default defineEventHandler( async (celebration) =&gt const physical body = wait for readBody( event).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hello there world',.html: body.template,..await transporter.sendMail( options). ).If you are actually not making use of the hosting server in nuxt, you may effortlessly carry out on any type of structure as an example utilizing share:.import show coming from 'share'.bring in nodemailer coming from 'nodemailer'.const application = show().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const layout = 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,..await transporter.sendMail( alternatives).profit res.json( information: "Email sent" ). ).app.listen( 3001 ).Documents.Receive the total documentation [listed below] ().Components.You may see the components, listed here:.Assimilations.E-mails built along with vue-email can be exchanged HTML or.clear text, as well as sent using any sort of e-mail provider. You can view.examples listed below:.