Sleep

Vue- Email - Vue.js Nourished

.Vue-email is influenced through react-email, it allows our team generate themes using the vue structure, with components that assist our team create templates easily as well as fast.To start utilizing vue-email in any kind of vue task, you only need to have to set up the deal:.With NPM:.$ npm put up vue-email.Along with Anecdote:.$ yarn incorporate vue-email.With PNPM:.$ pnpm mount vue-email.Making email layout.Develop a brand new email layout in everywhere you want to have your design templates, for this instance, our company can easily produce a theme folder, with a template called welcome.vue.src/templates/welcome. vue.

title, welcome to vue-email.A Vue element collection for structure responsive emails.Perspective on GitHub.Happy coding!David Arenas.
Providing the themes.We may make use of the leave functionality, it acquires 2 params, the first one is actually the design template to make, and the second the params to be used for the theme, and afterwards pass the outcome theme in the physical body of request.Passing the design template in the body, give us the possibility of rendering making use of any type of hosting server, express, fastify, nuxt in SSR, etc src/pages/index. vue.Send out e-mail along with nodemailer.Emailed email.
Send email.Within this example i making use of nuxt v3 given that it enables us to prepare api inside own project, and also specify several api options.Right here our team just draw out the design template of the request body, and send out the e-mail passing the theme in the sendMail function of the nodemailer deal.src/server/api/ email.post.ts.bring in nodemailer coming from 'nodemailer'.export default defineEventHandler( async (celebration) =&gt const body system = await readBody( event).const testAccount = wait for nodemailer.createTestAccount().const transporter = nodemailer.createTransport( 'smtp.ethereal.email',.port: 587,.protected: untrue,.auth: consumer: testAccount.user,.successfully pass: testAccount.pass,.,. ).const options = coming from: 'you@example.com',.to: 'user@gmail.com',.topic: 'hello there world',.html: body.template,..wait for transporter.sendMail( possibilities). ).If you are actually not using the server in nuxt, you may effortlessly carry out on any kind of structure as an example utilizing reveal:.import show coming from 'convey'.import nodemailer coming from 'nodemailer'.const application = show().app.use( express.json()).app.post('/ api/send-email', async (req, res) =&gt const layout = req.body.const testAccount = wait for nodemailer.createTestAccount().const carrier = nodemailer.createTransport( 'smtp.ethereal.email',.slot: 587,.secure: untrue,.auth: consumer: testAccount.user,.successfully pass: testAccount.pass,.,. ).const possibilities = coming from: 'you@example.com',.to: 'user@gmail.com',.target: 'greetings planet',.html: theme,..wait for transporter.sendMail( alternatives).return res.json( notification: "Email sent" ). ).app.listen( 3001 ).Records.Obtain the complete records [right here] ().Elements.You can easily observe the components, listed below:.Assimilations.E-mails built along with vue-email may be exchanged HTML or.clear text, and sent making use of any kind of e-mail provider. You may observe.examples here:.