Sleep

Vue- Email - Vue.js Supplied

.Vue-email is motivated through react-email, it allows our team develop templates using the vue framework, along with parts that aid our team construct design templates easily and also quick.To start using vue-email in any sort of vue task, you only require to put in the bundle:.With NPM:.$ npm set up vue-email.With Anecdote:.$ yarn include vue-email.With PNPM:.$ pnpm set up vue-email.Developing email design template.Generate a brand-new e-mail theme in wherever you want to have your themes, for this case, we may generate a theme file, along with a template gotten in touch with welcome.vue.src/templates/welcome. vue.

name, invited to vue-email.A Vue element public library for building reactive emails.Perspective on GitHub.Satisfied coding!David Arenas.
Making the design templates.We can make use of the leave function, it gets pair of params, the initial one is the design template to provide, and the second the params to become used for the layout, and then pass the result design template in the body of ask for.Passing the layout in the body, offer our company the possibility of rendering using any type of web server, convey, fastify, nuxt in SSR, and so on src/pages/index. vue.Send out e-mail with nodemailer.Emailed e-mail.
Send out email.In this particular instance i making use of nuxt v3 due to the fact that it allows our team to specify api inside own project, and also describe numerous api routes.Here our company just remove the layout of the ask for physical body, as well as deliver the email passing the template in the sendMail feature of the nodemailer bundle.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (event) =&gt const body = wait for readBody( event).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hey there globe',.html: body.template,..wait for transporter.sendMail( alternatives). ).If you are not using the web server in nuxt, you may effortlessly carry out on any kind of framework for instance utilizing show:.bring reveal coming from 'show'.import nodemailer coming from 'nodemailer'.const app = reveal().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const theme = req.body.const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.safe and secure: misleading,.auth: customer: testAccount.user,.elapsed: testAccount.pass,.,. ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.target: 'hey there globe',.html: layout,..await transporter.sendMail( alternatives).profit res.json( information: "Email sent out" ). ).app.listen( 3001 ).Information.Obtain the complete records [below] ().Parts.You can easily see the elements, listed here:.Combinations.Emails developed along with vue-email could be exchanged HTML or.clear text, and also sent out utilizing any sort of e-mail service provider. You may observe.examples right here:.