.Vue-email is actually inspired by react-email, it allows our team generate themes making use of the vue structure, with parts that help our team develop design templates effortlessly and quickly.To begin utilizing vue-email in any vue project, you only need to put up the package deal:.Along with NPM:.$ npm set up vue-email.Along with Yarn:.$ anecdote incorporate vue-email.Along with PNPM:.$ pnpm set up vue-email.Generating email design template.Make a new email template in anywhere you desire to have your layouts, for this scenario, our company may create a theme folder, with a design template called welcome.vue.src/templates/welcome. vue.
name, invited to vue-email.A Vue part public library for building receptive emails.View on GitHub.Satisfied coding!David Arenas.
Rendering the design templates.Our experts can use the make functionality, it receives two params, the very first one is the template to provide, and the second the params to become utilized for the design template, and after that pass the end result template in the body system of request.Passing the design template in the body, offer us the odds of rendering utilizing any type of hosting server, convey, fastify, nuxt in SSR, etc src/pages/index. vue.Send out e-mail with nodemailer.Placed e-mail.
Send e-mail.In this instance i making use of nuxt v3 considering that it permits our team to set api inside very own task, and describe multiple api options.Below our team only extract the theme of the ask for physical body, as well as deliver the email passing the theme in the sendMail function of the nodemailer deal.src/server/api/ email.post.ts.import nodemailer from 'nodemailer'.export default defineEventHandler( async (activity) => const physical body = wait for readBody( celebration).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const options = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hey there world',.html: body.template,..wait for transporter.sendMail( choices). ).If you are actually certainly not making use of the hosting server in nuxt, you can easily implement on any framework as an example using share:.import show from 'convey'.import nodemailer coming from 'nodemailer'.const application = convey().app.use( express.json()).app.post('/ api/send-email', async (req, res) => const theme = req.body.const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.safe: false,.auth: user: testAccount.user,.successfully pass: testAccount.pass,.,. ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.target: 'hi there globe',.html: template,..wait for transporter.sendMail( alternatives).profit res.json( information: "Email sent out" ). ).app.listen( 3001 ).Paperwork.Get the full documentation [listed here] ().Parts.You can easily observe the parts, listed below:.Combinations.Emails built along with vue-email could be exchanged HTML or.plain text, as well as sent out making use of any kind of email company. You can easily see.examples below:.