Sleep

Vue- Email - Vue.js Nourished

.Vue-email is inspired by react-email, it allows our team make themes utilizing the vue platform, with components that assist our company construct layouts quickly and swiftly.To start making use of vue-email in any kind of vue task, you just require to install the deal:.Along with NPM:.$ npm put up vue-email.Along with Yarn:.$ anecdote incorporate vue-email.With PNPM:.$ pnpm mount vue-email.Developing email design template.Generate a brand new email layout in everywhere you desire to possess your templates, for this case, we can create a theme file, along with a template called welcome.vue.src/templates/welcome. vue.

title, welcome to vue-email.A Vue part collection for property responsive e-mails.Sight on GitHub.Pleased coding!David Arenas.
Rendering the templates.We can make use of the render feature, it obtains pair of params, the 1st one is actually the theme to make, as well as the 2nd the params to be made use of for the design template, and then pass the outcome layout in the body of ask for.Passing the design template in the physical body, provide our company the chance of leaving making use of any hosting server, reveal, fastify, nuxt in SSR, etc src/pages/index. vue.Send out email along with nodemailer.Shipped email.
Deliver email.In this particular instance i making use of nuxt v3 since it allows us to prepare api inside very own venture, and also describe several api paths.Right here our experts just draw out the template of the request physical body, and send out the e-mail passing the design template in the sendMail feature of the nodemailer deal.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export default defineEventHandler( async (occasion) =&gt const body system = wait for readBody( occasion).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.safe and secure: false,.auth: user: testAccount.user,.elapsed: testAccount.pass,.,. ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hi world',.html: body.template,..await transporter.sendMail( alternatives). ).If you are actually certainly not making use of the web server in nuxt, you may conveniently apply on any platform for example utilizing express:.bring show from 'reveal'.bring in nodemailer from 'nodemailer'.const application = reveal().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const design template = req.body.const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.safe: misleading,.auth: customer: testAccount.user,.successfully pass: testAccount.pass,.,. ).const alternatives = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hi world',.html: layout,..wait for transporter.sendMail( options).yield res.json( information: "Email sent out" ). ).app.listen( 3001 ).Records.Obtain the full paperwork [here] ().Elements.You can see the parts, listed here:.Combinations.E-mails built along with vue-email may be converted into HTML or.clear text, as well as delivered utilizing any sort of email service provider. You can see.instances right here:.

Articles You Can Be Interested In