Sleep

Vue- Email - Vue.js Nourished

.Vue-email is actually influenced by react-email, it allows us create design templates making use of the vue framework, with parts that aid our company develop layouts easily and quickly.To start using vue-email in any type of vue task, you just need to put in the package deal:.With NPM:.$ npm put in vue-email.Along with Yarn:.$ anecdote incorporate vue-email.With PNPM:.$ pnpm set up vue-email.Making email theme.Generate a brand new email design template in anywhere you want to have your design templates, for this scenario, our experts can easily make a layout directory, with a template gotten in touch with welcome.vue.src/templates/welcome. vue.

name, invited to vue-email.A Vue component public library for building responsive emails.Sight on GitHub.Delighted coding!David Arenas.
Leaving the design templates.Our company can use the provide feature, it receives pair of params, the initial one is actually the layout to leave, and the second the params to become utilized for the layout, and after that pass the end result theme in the body system of request.Passing the design template in the body, offer our company the odds of making utilizing any kind of hosting server, show, fastify, nuxt in SSR, etc src/pages/index. vue.Send e-mail with nodemailer.Provided email.
Deliver email.Within this example i utilizing nuxt v3 since it permits our company to specify api inside very own venture, and define numerous api paths.Listed here we just extract the layout of the ask for body system, and send out the email passing the theme in the sendMail feature of the nodemailer deal.src/server/api/ email.post.ts.import nodemailer coming from 'nodemailer'.export nonpayment defineEventHandler( async (event) =&gt const body = await readBody( occasion).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const options = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hi planet',.html: body.template,..await transporter.sendMail( alternatives). ).If you are actually not making use of the server in nuxt, you can easily execute on any kind of structure for instance utilizing show:.import show coming from 'share'.bring in nodemailer from 'nodemailer'.const application = share().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const theme = req.body.const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const possibilities = from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hey there globe',.html: layout,..await transporter.sendMail( possibilities).profit res.json( message: "Email sent" ). ).app.listen( 3001 ).Records.Receive the full information [right here] ().Elements.You may view the components, listed below:.Assimilations.E-mails built with vue-email may be converted into HTML or even.clear text, as well as delivered using any type of email provider. You may observe.examples listed below:.