Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually inspired through react-email, it enables our team generate themes utilizing the vue platform, with elements that help us construct layouts simply as well as swiftly.To start using vue-email in any kind of vue task, you merely need to have to put up the bundle:.Along with NPM:.$ npm set up vue-email.With Yarn:.$ anecdote include vue-email.With PNPM:.$ pnpm set up vue-email.Making email design template.Produce a brand new email theme in no matter where you desire to possess your templates, for this case, our team can easily generate a layout folder, with a design template phoned welcome.vue.src/templates/welcome. vue.

label, appreciated to vue-email.A Vue component collection for building responsive e-mails.View on GitHub.Delighted coding!David Arenas.
Rendering the design templates.Our company can easily utilize the provide feature, it gets pair of params, the 1st one is actually the design template to provide, as well as the 2nd the params to be utilized for the theme, and then pass the result design template in the body system of ask for.Passing the layout in the body system, provide our team the opportunity of providing making use of any type of web server, reveal, fastify, nuxt in SSR, and so on src/pages/index. vue.Send out e-mail with nodemailer.Mailed email.
Send out email.In this example i using nuxt v3 since it permits our team to establish api inside own venture, as well as specify several api courses.Here our team just remove the theme of the ask for physical body, as well as send out the e-mail passing the template in the sendMail functionality of the nodemailer deal.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export nonpayment defineEventHandler( async (event) =&gt const body system = wait for readBody( occasion).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( host: process.env.HOST ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hi there planet',.html: body.template,..await transporter.sendMail( choices). ).If you are actually not using the web server in nuxt, you can quickly execute on any type of framework as an example using show:.bring reveal coming from 'share'.bring in nodemailer from 'nodemailer'.const application = show().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const layout = req.body.const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.safe: inaccurate,.auth: consumer: testAccount.user,.elapsed: testAccount.pass,.,. ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hi planet',.html: layout,..await transporter.sendMail( alternatives).yield res.json( message: "Email delivered" ). ).app.listen( 3001 ).Documentation.Obtain the complete paperwork [listed here] ().Parts.You may view the components, listed here:.Assimilations.E-mails created with vue-email could be converted into HTML or.clear text, and sent using any email company. You can easily find.examples right here:.