Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually motivated by react-email, it allows our company develop themes using the vue structure, along with components that aid our team construct themes conveniently as well as quick.To begin utilizing vue-email in any kind of vue venture, you only need to have to mount the deal:.With NPM:.$ npm put up vue-email.Along with Yarn:.$ anecdote incorporate vue-email.Along with PNPM:.$ pnpm put in vue-email.Producing e-mail theme.Create a new e-mail design template in any place you want to have your themes, for this scenario, our team may create a template directory, with a template gotten in touch with welcome.vue.src/templates/welcome. vue.

label, invited to vue-email.A Vue component collection for building reactive e-mails.Perspective on GitHub.Happy coding!David Arenas.
Rendering the themes.We may utilize the leave feature, it obtains two params, the initial one is actually the layout to leave, as well as the second the params to become used for the template, and then pass the outcome design template in the body system of request.Passing the design template in the physical body, offer our team the possibility of leaving utilizing any hosting server, show, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver email with nodemailer.Shipped e-mail.
Send out email.In this instance i using nuxt v3 since it enables us to specify api inside very own project, and also specify multiple api courses.Below our experts only draw out the layout of the request body, and also send out the email passing the design template in the sendMail function of the nodemailer package.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export nonpayment defineEventHandler( async (occasion) =&gt const body = await readBody( occasion).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( host: process.env.HOST ).const choices = from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hey there globe',.html: body.template,..wait for transporter.sendMail( choices). ).If you are actually not utilizing the hosting server in nuxt, you can easily implement on any type of framework for instance making use of reveal:.bring express coming from 'share'.import nodemailer coming from 'nodemailer'.const app = share().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( 'smtp.ethereal.email',.slot: 587,.safe: misleading,.auth: user: testAccount.user,.elapsed: testAccount.pass,.,. ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hello planet',.html: design template,..await transporter.sendMail( possibilities).return res.json( information: "Email sent" ). ).app.listen( 3001 ).Documents.Obtain the complete records [listed here] ().Components.You can easily find the parts, listed here:.Combinations.Emails created along with vue-email can be converted into HTML or even.clear text, and also sent making use of any sort of email service provider. You can easily see.instances below:.