Sleep

Vue- Email - Vue.js Supplied

.Vue-email is inspired by react-email, it allows our team develop themes making use of the vue structure, with parts that assist our team develop templates simply as well as quick.To start using vue-email in any vue venture, you just need to have to set up the deal:.With NPM:.$ npm install vue-email.Along with Yarn:.$ anecdote add vue-email.With PNPM:.$ pnpm put up vue-email.Making email design template.Make a brand-new email design template in any place you wish to have your themes, for this scenario, our company can generate a theme folder, along with a design template called welcome.vue.src/templates/welcome. vue.

name, appreciated to vue-email.A Vue element public library for property responsive emails.Sight on GitHub.Delighted coding!David Arenas.
Rendering the templates.Our team can utilize the make feature, it receives pair of params, the initial one is actually the theme to make, and the second the params to be used for the theme, and after that pass the end result template in the body system of ask for.Passing the design template in the body system, provide our team the chance of rendering utilizing any hosting server, convey, fastify, nuxt in SSR, and so on src/pages/index. vue.Deliver e-mail along with nodemailer.Mailed email.
Send out e-mail.In this example i making use of nuxt v3 because it enables our team to establish api inside personal task, as well as specify numerous api routes.Here our team just remove the design template of the ask for physical body, and deliver the e-mail passing the template in the sendMail functionality of the nodemailer plan.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export default defineEventHandler( async (celebration) =&gt const body = await readBody( activity).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hey there planet',.html: body.template,..await transporter.sendMail( choices). ).If you are certainly not making use of the hosting server in nuxt, you may conveniently execute on any framework for instance making use of show:.bring express coming from 'show'.bring in nodemailer coming from 'nodemailer'.const application = express().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( ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hi there planet',.html: design template,..await transporter.sendMail( alternatives).return res.json( message: "Email delivered" ). ).app.listen( 3001 ).Documentation.Obtain the complete information [listed here] ().Components.You can easily view the components, listed below:.Assimilations.Emails built along with vue-email may be converted into HTML or even.plain text, as well as delivered utilizing any e-mail provider. You may find.instances listed below:.