Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually encouraged through react-email, it enables our company create design templates using the vue structure, along with parts that aid us construct templates effortlessly as well as quickly.To start using vue-email in any type of vue project, you just need to have to mount the deal:.Along with NPM:.$ npm mount vue-email.Along with Anecdote:.$ anecdote include vue-email.With PNPM:.$ pnpm set up vue-email.Making e-mail theme.Produce a brand-new email template in everywhere you would like to have your themes, for this instance, we can produce a design template folder, along with a template phoned welcome.vue.src/templates/welcome. vue.

title, invited to vue-email.A Vue element public library for property reactive e-mails.Scenery on GitHub.Pleased coding!David Arenas.
Providing the themes.We can utilize the provide function, it acquires pair of params, the 1st one is the layout to make, and the 2nd the params to become utilized for the theme, and after that pass the end result template in the body of request.Passing the template in the body, give our company the odds of making using any type of server, express, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver email with nodemailer.Provided email.
Send e-mail.In this example i utilizing nuxt v3 since it enables us to set api inside own task, and determine multiple api paths.Here our company simply draw out the theme of the request body system, and send the email passing the template 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 physical body = await readBody( event).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( bunch: process.env.HOST ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hi planet',.html: body.template,..await transporter.sendMail( possibilities). ).If you are not utilizing the web server in nuxt, you may conveniently execute on any sort of structure for example using show:.import show coming from 'reveal'.bring in nodemailer coming from 'nodemailer'.const application = reveal().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const design template = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.secure: untrue,.auth: individual: testAccount.user,.successfully pass: testAccount.pass,.,. ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.target: 'hi there globe',.html: design template,..wait for transporter.sendMail( choices).gain res.json( information: "Email sent" ). ).app.listen( 3001 ).Paperwork.Obtain the complete records [listed below] ().Parts.You can observe the elements, listed here:.Assimilations.Emails created along with vue-email could be converted into HTML or.plain text, as well as sent out making use of any kind of email specialist. You can easily view.instances right here:.