Sleep

Vue- Email - Vue.js Nourished

.Vue-email is inspired by react-email, it permits our team make design templates making use of the vue structure, with components that aid us build design templates simply as well as quickly.To start using vue-email in any kind of vue project, you just require to put up the package deal:.With NPM:.$ npm mount vue-email.With Yarn:.$ anecdote add vue-email.With PNPM:.$ pnpm mount vue-email.Making email theme.Create a brand-new e-mail theme in anywhere you intend to have your themes, for this instance, our company can easily make a template directory, with a theme contacted welcome.vue.src/templates/welcome. vue.

title, appreciated to vue-email.A Vue part collection for structure receptive emails.Scenery on GitHub.Delighted coding!David Arenas.
Leaving the templates.Our company can easily utilize the render functionality, it acquires two params, the initial one is the template to leave, as well as the 2nd the params to become used for the theme, and then pass the outcome theme in the body system of ask for.Passing the design template in the body system, give our team the possibility of leaving using any sort of web server, show, fastify, nuxt in SSR, etc src/pages/index. vue.Send out e-mail along with nodemailer.Posted email.
Send e-mail.In this particular example i using nuxt v3 because it permits our company to set api inside personal task, and describe a number of api courses.Listed here we only extract the theme of the ask for body, and deliver the e-mail passing the theme in the sendMail feature of the nodemailer package.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export nonpayment defineEventHandler( async (activity) =&gt const physical body = await readBody( celebration).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( host: process.env.HOST ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.target: 'greetings globe',.html: body.template,..wait for transporter.sendMail( choices). ).If you are not using the server in nuxt, you can conveniently implement on any sort of structure for instance using share:.import express coming from 'show'.import nodemailer from 'nodemailer'.const app = show().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const template = req.body.const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const alternatives = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hello globe',.html: design template,..await transporter.sendMail( choices).profit res.json( information: "Email sent" ). ).app.listen( 3001 ).Documentation.Obtain the complete information [below] ().Parts.You can easily find the components, listed here:.Integrations.Emails constructed along with vue-email can be converted into HTML or even.clear text, and also sent out utilizing any e-mail company. You can easily see.examples listed here:.