Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually influenced by react-email, it allows our team generate templates making use of the vue platform, along with elements that assist our company build templates simply and fast.To start making use of vue-email in any kind of vue task, you simply need to have to mount the bundle:.With NPM:.$ npm mount vue-email.With Yarn:.$ yarn incorporate vue-email.Along with PNPM:.$ pnpm install vue-email.Creating e-mail design template.Develop a new e-mail template in any place you desire to have your layouts, for this instance, our company can produce a template file, along with a layout phoned welcome.vue.src/templates/welcome. vue.

title, appreciated to vue-email.A Vue part collection for structure responsive emails.Perspective on GitHub.Satisfied coding!David Arenas.
Rendering the design templates.Our team can easily use the leave function, it gets 2 params, the initial one is the design template to leave, as well as the 2nd the params to become utilized for the template, and afterwards pass the end result template in the body of request.Passing the theme in the physical body, give our company the possibility of providing making use of any sort of server, share, fastify, nuxt in SSR, etc src/pages/index. vue.Send out e-mail with nodemailer.Shipped email.
Send e-mail.Within this example i making use of nuxt v3 due to the fact that it permits our team to set api inside own job, as well as describe multiple api paths.Listed here our experts only draw out the design template of the ask for physical body, as well as send the email passing the design template in the sendMail functionality of the nodemailer package deal.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export default defineEventHandler( async (occasion) =&gt const body system = await readBody( occasion).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( bunch: process.env.HOST ).const options = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hi there globe',.html: body.template,..wait for transporter.sendMail( choices). ).If you are actually certainly not utilizing the server in nuxt, you can easily implement on any structure for example using show:.import reveal from 'show'.bring in nodemailer coming from 'nodemailer'.const app = share().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const template = req.body.const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( multitude: process.env.HOST ).const options = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'greetings globe',.html: theme,..await transporter.sendMail( alternatives).yield res.json( message: "Email delivered" ). ).app.listen( 3001 ).Paperwork.Receive the full records [right here] ().Parts.You may observe the components, listed below:.Assimilations.E-mails created with vue-email can be exchanged HTML or.clear text, as well as sent out making use of any kind of e-mail service provider. You can easily find.instances below:.