Sleep

Vue- Email - Vue.js Supplied

.Vue-email is encouraged through react-email, it enables us develop design templates utilizing the vue platform, with elements that assist us build templates simply and also quick.To start using vue-email in any kind of vue project, you merely need to have to put up the deal:.Along with NPM:.$ npm put up vue-email.Along with Yarn:.$ anecdote incorporate vue-email.With PNPM:.$ pnpm mount vue-email.Making e-mail design template.Develop a brand-new email theme in wherever you would like to have your themes, for this case, our experts can create a theme directory, with a layout gotten in touch with welcome.vue.src/templates/welcome. vue.

label, appreciated to vue-email.A Vue part public library for structure responsive e-mails.Sight on GitHub.Pleased coding!David Arenas.
Making the templates.Our experts can use the render function, it gets pair of params, the initial one is actually the design template to render, and the second the params to become utilized for the layout, and then pass the outcome layout in the body of demand.Passing the theme in the physical body, offer our company the opportunity of rendering making use of any web server, convey, fastify, nuxt in SSR, etc src/pages/index. vue.Deliver e-mail along with nodemailer.Dispatched email.
Deliver e-mail.In this example i using nuxt v3 given that it allows us to establish api inside own venture, as well as determine multiple api paths.Here our company simply draw out the layout of the request body, and deliver the e-mail passing the template in the sendMail functionality of the nodemailer package.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export default defineEventHandler( async (celebration) =&gt const body system = await readBody( celebration).const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.subject matter: 'hi there world',.html: body.template,..await transporter.sendMail( possibilities). ).If you are actually certainly not making use of the web server in nuxt, you may conveniently implement on any sort of framework as an example using convey:.import reveal from 'show'.bring in nodemailer from 'nodemailer'.const application = share().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const design template = req.body.const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.protected: inaccurate,.auth: user: testAccount.user,.elapsed: testAccount.pass,.,. ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.subject: 'hello there world',.html: theme,..await transporter.sendMail( alternatives).profit res.json( notification: "Email sent" ). ).app.listen( 3001 ).Documents.Obtain the full records [here] ().Components.You may view the components, listed here:.Assimilations.E-mails built with vue-email could be exchanged HTML or.clear text, and sent utilizing any kind of e-mail service provider. You can easily observe.examples listed here:.