Sleep

Vue- Email - Vue.js Feed

.Vue-email is actually motivated by react-email, it permits our company develop design templates utilizing the vue framework, with parts that aid us construct layouts quickly as well as quick.To begin using vue-email in any type of vue project, you only require to put up the plan:.With NPM:.$ npm mount vue-email.With Anecdote:.$ anecdote add vue-email.Along with PNPM:.$ pnpm mount vue-email.Creating email template.Create a brand-new e-mail theme in wherever you intend to have your templates, for this instance, we can create a template folder, along with a theme contacted welcome.vue.src/templates/welcome. vue.

label, invited to vue-email.A Vue element public library for structure responsive emails.Perspective on GitHub.Happy coding!David Arenas.
Rendering the templates.Our team may utilize the render feature, it acquires two params, the initial one is actually the template to leave, and the second the params to be used for the layout, and afterwards pass the result theme in the body system of demand.Passing the design template in the body, offer us the possibility of rendering using any server, convey, fastify, nuxt in SSR, and so on src/pages/index. vue.Send e-mail with nodemailer.Routed email.
Send out email.In this instance i making use of nuxt v3 considering that it permits us to specify api inside own job, as well as determine several api routes.Right here our team just remove the theme of the demand body system, and also send out the e-mail passing the design template in the sendMail function of the nodemailer package.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export nonpayment defineEventHandler( async (occasion) =&gt const body = await readBody( celebration).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const options = from: 'you@example.com',.to: 'user@gmail.com',.target: 'hello planet',.html: body.template,..await transporter.sendMail( options). ).If you are actually not utilizing the web server in nuxt, you may effortlessly execute on any type of platform for example using share:.bring convey coming from 'show'.bring in nodemailer from 'nodemailer'.const app = reveal().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',.port: 587,.safe: incorrect,.auth: individual: testAccount.user,.elapsed: testAccount.pass,.,. ).const alternatives = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hi globe',.html: layout,..await transporter.sendMail( possibilities).gain res.json( message: "Email delivered" ). ).app.listen( 3001 ).Records.Acquire the complete documentation [listed below] ().Components.You can find the parts, listed below:.Combinations.E-mails built along with vue-email may be exchanged HTML or even.clear text, and also delivered using any kind of email company. You may observe.instances listed below:.