Sleep

Vue- Email - Vue.js Nourished

.Vue-email is inspired through react-email, it enables our company create templates utilizing the vue platform, with components that help our company develop templates quickly and also quick.To begin utilizing vue-email in any kind of vue venture, you just need to install the deal:.Along with NPM:.$ npm set up vue-email.Along with Anecdote:.$ anecdote add vue-email.Along with PNPM:.$ pnpm put in vue-email.Creating email design template.Produce a brand-new email design template in any place you intend to possess your templates, for this scenario, our team can easily generate a theme file, along with a layout phoned welcome.vue.src/templates/welcome. vue.

title, invited to vue-email.A Vue part library for building receptive emails.Perspective on GitHub.Happy coding!David Arenas.
Leaving the layouts.Our experts can easily make use of the leave feature, it gets 2 params, the initial one is actually the layout to leave, and also the 2nd the params to be made use of for the design template, and afterwards pass the result layout in the body system of ask for.Passing the template in the physical body, offer our team the possibility of rendering utilizing any kind of web server, share, fastify, nuxt in SSR, and so on src/pages/index. vue.Send out e-mail with nodemailer.Delivered email.
Send email.In this particular example i making use of nuxt v3 because it enables our team to set api inside very own venture, and determine multiple api routes.Here our company merely extract the theme of the ask for body, and also send the email passing the theme in the sendMail functionality of the nodemailer package.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (activity) =&gt const body system = wait for readBody( activity).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hello there world',.html: body.template,..await transporter.sendMail( alternatives). ).If you are certainly not utilizing the server in nuxt, you can conveniently implement on any kind of structure as an example making use of express:.bring share from 'convey'.bring in nodemailer coming from 'nodemailer'.const app = reveal().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( host: process.env.HOST ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'greetings planet',.html: layout,..wait for transporter.sendMail( possibilities).yield res.json( information: "Email delivered" ). ).app.listen( 3001 ).Paperwork.Receive the complete records [listed here] ().Parts.You may view the components, listed here:.Combinations.Emails constructed along with vue-email can be converted into HTML or.plain text, as well as sent out using any kind of e-mail service provider. You can easily view.examples below:.