Sleep

Vue- Email - Vue.js Nourished

.Vue-email is inspired through react-email, it allows our company produce themes utilizing the vue framework, with parts that aid our company build design templates easily and swiftly.To start utilizing vue-email in any type of vue job, you simply require to put in the package deal:.With NPM:.$ npm set up vue-email.Along with Anecdote:.$ anecdote add vue-email.With PNPM:.$ pnpm install vue-email.Producing email template.Develop a brand-new e-mail theme in any place you desire to have your design templates, for this case, our experts can develop a design template directory, along with a layout called welcome.vue.src/templates/welcome. vue.

label, appreciated to vue-email.A Vue element library for building reactive e-mails.Viewpoint on GitHub.Delighted coding!David Arenas.
Rendering the templates.Our experts can utilize the provide functionality, it obtains 2 params, the first one is the theme to provide, and the 2nd the params to be used for the theme, and then pass the outcome layout in the physical body of ask for.Passing the layout in the physical body, provide us the chance of leaving using any type of hosting server, reveal, fastify, nuxt in SSR, and so on src/pages/index. vue.Send out e-mail with nodemailer.Mailed e-mail.
Send email.Within this instance i using nuxt v3 due to the fact that it allows our team to set api inside very own venture, as well as determine several api routes.Right here we simply draw out the design template of the ask for physical body, as well as send out the email passing the theme in the sendMail function of the nodemailer package.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export nonpayment defineEventHandler( async (occasion) =&gt const body system = wait for readBody( activity).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.secure: incorrect,.auth: customer: testAccount.user,.elapsed: testAccount.pass,.,. ).const choices = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hello world',.html: body.template,..wait for transporter.sendMail( possibilities). ).If you are not utilizing the hosting server in nuxt, you may simply carry out on any kind of structure for example making use of convey:.bring share from 'express'.bring in nodemailer from 'nodemailer'.const app = express().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const layout = req.body.const testAccount = await nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.secure: inaccurate,.auth: consumer: testAccount.user,.successfully pass: testAccount.pass,.,. ).const alternatives = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hi there globe',.html: template,..await transporter.sendMail( choices).gain res.json( notification: "Email sent out" ). ).app.listen( 3001 ).Records.Obtain the total information [listed below] ().Components.You can easily see the elements, listed below:.Integrations.E-mails developed with vue-email may be exchanged HTML or.plain text, and also sent out making use of any kind of e-mail company. You may find.instances listed below:.