Sleep

Vue- Email - Vue.js Nourished

.Vue-email is motivated by react-email, it enables us create themes making use of the vue framework, along with parts that aid our company build themes simply and swiftly.To begin making use of vue-email in any vue venture, you just require to set up the package deal:.With NPM:.$ npm set up vue-email.With Yarn:.$ yarn add vue-email.With PNPM:.$ pnpm mount vue-email.Generating email theme.Generate a new e-mail theme in everywhere you wish to possess your design templates, for this instance, we can easily create a design template folder, with a layout gotten in touch with welcome.vue.src/templates/welcome. vue.

name, invited to vue-email.A Vue component collection for property receptive e-mails.View on GitHub.Happy coding!David Arenas.
Leaving the templates.Our team can easily use the leave function, it receives pair of params, the very first one is actually the layout to render, as well as the second the params to become utilized for the template, and after that pass the end result theme in the physical body of ask for.Passing the layout in the body, offer us the opportunity of providing making use of any type of hosting server, express, fastify, nuxt in SSR, etc src/pages/index. vue.Send email along with nodemailer.Dispatched e-mail.
Send email.In this instance i utilizing nuxt v3 considering that it enables us to prepare api inside personal job, and determine a number of api options.Right here our company just draw out the template of the request body, as well as send the e-mail passing the layout in the sendMail functionality of the nodemailer plan.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (event) =&gt const body system = await readBody( celebration).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.target: 'hi planet',.html: body.template,..wait for transporter.sendMail( possibilities). ).If you are actually certainly not using the web server in nuxt, you can effortlessly apply on any kind of framework for instance utilizing convey:.import share from 'convey'.import nodemailer coming from 'nodemailer'.const app = share().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const theme = req.body.const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.secure: misleading,.auth: customer: testAccount.user,.successfully pass: testAccount.pass,.,. ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hi world',.html: layout,..wait for transporter.sendMail( possibilities).yield res.json( message: "Email sent" ). ).app.listen( 3001 ).Documentation.Obtain the full documentation [here] ().Elements.You may observe the components, listed here:.Integrations.Emails built with vue-email may be exchanged HTML or.clear text, as well as sent making use of any e-mail service provider. You may view.examples here:.