Sleep

Vue- Email - Vue.js Supplied

.Vue-email is actually inspired through react-email, it allows us develop design templates making use of the vue platform, along with parts that assist our team develop layouts quickly and quick.To begin utilizing vue-email in any type of vue job, you simply need to put in the package deal:.Along with NPM:.$ npm put up vue-email.Along with Yarn:.$ yarn add vue-email.With PNPM:.$ pnpm put in vue-email.Producing email layout.Develop a brand new email layout in everywhere you desire to have your templates, for this situation, we can generate a theme folder, with a theme contacted welcome.vue.src/templates/welcome. vue.

title, invited to vue-email.A Vue element library for building responsive emails.View on GitHub.Happy coding!David Arenas.
Rendering the design templates.We can make use of the provide feature, it gets 2 params, the very first one is actually the design template to make, and the 2nd the params to become used for the design template, and after that pass the end result theme in the body of demand.Passing the design template in the physical body, provide our team the possibility of making making use of any type of web server, reveal, fastify, nuxt in SSR, etc src/pages/index. vue.Send out e-mail along with nodemailer.Delivered email.
Send e-mail.In this example i utilizing nuxt v3 considering that it enables our team to specify api inside very own job, and also describe numerous api routes.Here our experts simply draw out the template of the ask for physical body, and also deliver the email passing the layout in the sendMail functionality of the nodemailer package deal.src/server/api/ email.post.ts.bring in nodemailer from 'nodemailer'.export default defineEventHandler( async (activity) =&gt const body system = wait for readBody( occasion).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( lot: process.env.HOST ).const alternatives = coming from: 'you@example.com',.to: 'user@gmail.com',.target: 'hey there planet',.html: body.template,..await transporter.sendMail( options). ).If you are actually not using the hosting server in nuxt, you may simply carry out on any platform for example utilizing show:.bring reveal coming from 'share'.import nodemailer from 'nodemailer'.const application = reveal().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const theme = req.body.const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( ).const options = from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hey there world',.html: design template,..await transporter.sendMail( choices).profit res.json( information: "Email sent" ). ).app.listen( 3001 ).Documents.Receive the full paperwork [listed here] ().Elements.You may observe the elements, listed here:.Combinations.E-mails constructed along with vue-email can be exchanged HTML or even.plain text, as well as delivered utilizing any type of e-mail company. You may view.examples here:.

Articles You Can Be Interested In