Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually motivated through react-email, it enables our team make templates utilizing the vue framework, with elements that aid us construct layouts easily and also quick.To begin using vue-email in any kind of vue project, you only require to put up the package deal:.With NPM:.$ npm set up vue-email.With Anecdote:.$ anecdote incorporate vue-email.With PNPM:.$ pnpm put up vue-email.Producing e-mail theme.Produce a brand-new email theme in anywhere you want to possess your design templates, for this instance, our company can easily produce a layout directory, with a layout phoned welcome.vue.src/templates/welcome. vue.

label, invited to vue-email.A Vue element public library for building receptive emails.Scenery on GitHub.Happy coding!David Arenas.
Making the design templates.Our experts can make use of the render functionality, it receives two params, the initial one is actually the design template to render, and also the second the params to become used for the theme, and then pass the end result layout in the physical body of request.Passing the theme in the body system, give our team the chance of providing making use of any kind of hosting server, share, fastify, nuxt in SSR, and so on src/pages/index. vue.Send out e-mail along with nodemailer.Delivered e-mail.
Send out email.Within this instance i utilizing nuxt v3 considering that it allows us to set api inside own task, and also describe various api options.Listed below we just remove the design template of the demand body, as well as send out the email passing the theme in the sendMail functionality of the nodemailer plan.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (event) =&gt const body system = wait for readBody( activity).const testAccount = await nodemailer.createTestAccount().const transporter = nodemailer.createTransport( lot: process.env.HOST ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'greetings globe',.html: body.template,..wait for transporter.sendMail( possibilities). ).If you are certainly not utilizing the web server in nuxt, you may simply execute on any kind of platform for instance making use of reveal:.bring show coming from 'reveal'.bring in nodemailer coming from 'nodemailer'.const app = reveal().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const design template = req.body.const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.safe: misleading,.auth: individual: testAccount.user,.successfully pass: testAccount.pass,.,. ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hello there planet',.html: layout,..await transporter.sendMail( options).yield res.json( notification: "Email sent out" ). ).app.listen( 3001 ).Documents.Obtain the total documents [below] ().Parts.You can easily see the parts, listed below:.Combinations.E-mails built with vue-email can be exchanged HTML or even.plain text, and sent making use of any sort of email provider. You can easily observe.examples listed below:.

Articles You Can Be Interested In