Sleep

Vue- Email - Vue.js Nourished

.Vue-email is actually motivated through react-email, it enables our company create themes utilizing the vue structure, with parts that assist our company build templates effortlessly and also swiftly.To start using vue-email in any vue venture, you just need to have to install the plan:.Along with NPM:.$ npm put up vue-email.With Yarn:.$ anecdote incorporate vue-email.Along with PNPM:.$ pnpm put in vue-email.Making email theme.Develop a brand new email template in no matter where you intend to have your design templates, for this instance, our company can create a template directory, with a layout gotten in touch with welcome.vue.src/templates/welcome. vue.

label, invited to vue-email.A Vue component collection for building reactive e-mails.Perspective on GitHub.Satisfied coding!David Arenas.
Making the templates.Our company can easily make use of the render feature, it obtains two params, the 1st one is actually the layout to render, and also the second the params to be used for the design template, and after that pass the outcome layout in the body system of request.Passing the design template in the body system, offer our company the odds of leaving using any type of server, share, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver e-mail with nodemailer.Dispatched e-mail.
Send out email.In this example i using nuxt v3 given that it permits our company to establish api inside very own project, as well as specify multiple api courses.Listed here our experts only extract the layout of the demand body, as well as send out the e-mail passing the template in the sendMail feature of the nodemailer package.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export default defineEventHandler( async (occasion) =&gt const body = await readBody( activity).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hi there globe',.html: body.template,..wait for transporter.sendMail( choices). ).If you are actually certainly not using the web server in nuxt, you may quickly execute on any type of framework as an example using share:.import reveal from 'share'.bring in nodemailer coming from 'nodemailer'.const app = reveal().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const template = req.body.const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.target: 'hello planet',.html: theme,..await transporter.sendMail( options).gain res.json( notification: "Email sent" ). ).app.listen( 3001 ).Paperwork.Acquire the complete paperwork [listed below] ().Parts.You can easily observe the elements, listed here:.Integrations.Emails built with vue-email can be converted into HTML or even.plain text, and also delivered utilizing any sort of email service provider. You may view.examples here:.