Sleep

Vue- Email - Vue.js Nourished

.Vue-email is inspired by react-email, it allows us generate themes making use of the vue structure, along with parts that assist us construct design templates quickly and swiftly.To begin using vue-email in any vue project, you simply need to have to put in the deal:.Along with NPM:.$ npm put in vue-email.With Anecdote:.$ yarn add vue-email.Along with PNPM:.$ pnpm mount vue-email.Developing email layout.Make a new email theme in any place you desire to have your layouts, for this case, our experts may produce a template directory, along with a theme gotten in touch with welcome.vue.src/templates/welcome. vue.

label, appreciated to vue-email.A Vue element public library for building reactive emails.Scenery on GitHub.Pleased coding!David Arenas.
Rendering the themes.Our team can easily use the leave feature, it receives two params, the very first one is actually the design template to make, and also the 2nd the params to become used for the layout, and afterwards pass the result theme in the body system of request.Passing the template in the body system, offer us the opportunity of providing using any hosting server, show, fastify, nuxt in SSR, and so on src/pages/index. vue.Send out email with nodemailer.Placed email.
Send out e-mail.In this particular instance i using nuxt v3 considering that it allows our company to specify api inside very own venture, as well as describe multiple api routes.Below our team just remove the theme of the request body, and also send the e-mail passing the layout in the sendMail feature of the nodemailer plan.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export default defineEventHandler( async (event) =&gt const body system = wait for readBody( celebration).const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( multitude: process.env.HOST ).const options = from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hello globe',.html: body.template,..await transporter.sendMail( options). ).If you are actually certainly not using the hosting server in nuxt, you may easily carry out on any type of structure as an example making use of share:.import reveal coming from 'share'.bring in nodemailer coming from 'nodemailer'.const application = show().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const theme = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.secure: misleading,.auth: individual: testAccount.user,.successfully pass: testAccount.pass,.,. ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hello planet',.html: template,..await transporter.sendMail( possibilities).profit res.json( notification: "Email sent out" ). ).app.listen( 3001 ).Documents.Get the complete information [here] ().Components.You can observe the components, listed here:.Integrations.E-mails built with vue-email can be exchanged HTML or even.plain text, and sent using any sort of e-mail service provider. You can observe.examples here:.