Sleep

Vue- Email - Vue.js Nourished

.Vue-email is actually influenced through react-email, it permits our team make templates using the vue framework, along with components that aid our team construct design templates effortlessly as well as quickly.To begin making use of vue-email in any sort of vue job, you just need to have to mount the plan:.Along with NPM:.$ npm put in vue-email.With Yarn:.$ yarn include vue-email.Along with PNPM:.$ pnpm install vue-email.Developing email template.Produce a brand new email template in wherever you would like to have your design templates, for this case, our experts can easily produce a theme file, with a theme contacted welcome.vue.src/templates/welcome. vue.

title, welcome to vue-email.A Vue part collection for building reactive e-mails.View on GitHub.Delighted coding!David Arenas.
Making the templates.Our team can easily use the leave function, it gets pair of params, the very first one is the design template to make, as well as the 2nd the params to become used for the design template, and afterwards pass the result template in the body of ask for.Passing the theme in the body, give us the chance of rendering making use of any kind of web server, show, fastify, nuxt in SSR, etc src/pages/index. vue.Send email along with nodemailer.Directed email.
Send out e-mail.In this particular instance i utilizing nuxt v3 since it permits us to establish api inside own job, and also define numerous api courses.Right here our company only draw out the template of the ask for body system, and also send the e-mail passing the design template in the sendMail function of the nodemailer bundle.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export default defineEventHandler( async (celebration) =&gt const body system = wait for readBody( event).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hi planet',.html: body.template,..wait for transporter.sendMail( alternatives). ).If you are certainly not making use of the hosting server in nuxt, you can simply implement on any kind of structure as an example making use of reveal:.bring reveal coming from 'reveal'.bring in nodemailer coming from 'nodemailer'.const app = share().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const layout = req.body.const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.safe: inaccurate,.auth: customer: testAccount.user,.pass: testAccount.pass,.,. ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hi world',.html: design template,..await transporter.sendMail( alternatives).profit res.json( notification: "Email sent" ). ).app.listen( 3001 ).Information.Get the complete paperwork [listed here] ().Components.You may observe the parts, listed here:.Assimilations.Emails developed along with vue-email could be exchanged HTML or.plain text, as well as sent making use of any e-mail specialist. You may view.instances below:.