Sleep

Vue- Email - Vue.js Nourished

.Vue-email is motivated through react-email, it enables our company create layouts making use of the vue framework, along with components that help us develop layouts quickly and also fast.To start utilizing vue-email in any vue job, you only need to set up the package deal:.With NPM:.$ npm put up vue-email.Along with Yarn:.$ yarn include vue-email.Along with PNPM:.$ pnpm install vue-email.Creating e-mail layout.Develop a brand-new email template in any place you would like to have your layouts, for this scenario, our experts can easily produce a layout directory, with a design template called welcome.vue.src/templates/welcome. vue.

label, welcome to vue-email.A Vue element library for property reactive e-mails.Viewpoint on GitHub.Delighted coding!David Arenas.
Providing the templates.Our team can make use of the render function, it receives two params, the very first one is actually the layout to render, as well as the 2nd the params to be used for the layout, and then pass the result layout in the body system of ask for.Passing the layout in the body system, provide our team the opportunity of providing utilizing any type of hosting server, express, fastify, nuxt in SSR, and so on src/pages/index. vue.Deliver e-mail with nodemailer.Provided email.
Send email.Within this example i utilizing nuxt v3 since it permits our company to establish api inside personal task, and describe various api paths.Below our experts just extract the theme of the request body system, and send the email 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 (celebration) =&gt const body system = await readBody( celebration).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.protected: false,.auth: user: testAccount.user,.elapsed: testAccount.pass,.,. ).const alternatives = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hello there globe',.html: body.template,..await transporter.sendMail( options). ).If you are actually not utilizing the web server in nuxt, you can conveniently carry out on any sort of structure for instance utilizing reveal:.import show coming from 'reveal'.import nodemailer from 'nodemailer'.const application = reveal().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( ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'greetings planet',.html: template,..await transporter.sendMail( options).yield res.json( information: "Email delivered" ). ).app.listen( 3001 ).Documentation.Get the full documentation [listed here] ().Parts.You can easily find the parts, listed below:.Integrations.Emails developed along with vue-email may be converted into HTML or even.plain text, and delivered using any email provider. You can see.examples right here:.