Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually motivated by react-email, it allows our team create layouts making use of the vue framework, with parts that assist our company build templates conveniently and also fast.To start using vue-email in any type of vue venture, you only need to mount the deal:.With NPM:.$ npm mount vue-email.With Anecdote:.$ anecdote add vue-email.Along with PNPM:.$ pnpm set up vue-email.Creating email design template.Generate a new e-mail template in no matter where you intend to have your design templates, for this instance, our experts may develop a template folder, along with a template contacted welcome.vue.src/templates/welcome. vue.

title, invited to vue-email.A Vue element library for building responsive e-mails.View on GitHub.Delighted coding!David Arenas.
Rendering the templates.Our team can easily use the provide functionality, it acquires pair of params, the initial one is actually the theme to provide, and the second the params to be made use of for the template, and then pass the end result theme in the body system of ask for.Passing the theme in the body, provide our team the possibility of rendering using any kind of server, show, fastify, nuxt in SSR, and so on src/pages/index. vue.Send e-mail along with nodemailer.Posted email.
Deliver email.In this example i making use of nuxt v3 because it enables our company to specify api inside personal job, and determine various api routes.Listed here our team simply draw out the layout of the demand body, and send out the email passing the theme in the sendMail feature of the nodemailer package deal.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export default defineEventHandler( async (occasion) =&gt const body system = wait for readBody( event).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.protected: untrue,.auth: individual: testAccount.user,.pass: testAccount.pass,.,. ).const options = from: 'you@example.com',.to: 'user@gmail.com',.target: 'hello there planet',.html: body.template,..await transporter.sendMail( possibilities). ).If you are not making use of the hosting server in nuxt, you can conveniently implement on any type of structure for example using share:.import convey coming from 'show'.import nodemailer from 'nodemailer'.const application = convey().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const template = req.body.const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( bunch: process.env.HOST ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.target: 'hello globe',.html: template,..await transporter.sendMail( choices).gain res.json( information: "Email sent out" ). ).app.listen( 3001 ).Information.Acquire the full documentation [here] ().Elements.You may find the components, listed below:.Assimilations.Emails created with vue-email could be exchanged HTML or even.clear text, as well as sent utilizing any email specialist. You can see.examples right here:.