yads / nodemailer-express-handlebars

A plugin for nodemailer that uses express-handlebars view engine to generate emails

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handlebars: Access has been denied to resolve the property "author" because it is not an "own property" of its parent. You can add a runtime option to disable the check or this warning: See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details

Wennlys opened this issue · comments

I've already to read Handlebars's documentation and topic about this problem but I didn't find anything related with nodemailer-express-handlebars


**Mail.js** = const path = require('path')
const nodemailer = require('nodemailer')
const handlebars = require('express-handlebars')
const hbs = require('nodemailer-express-handlebars')

const mailConfig = require('../../config/mail')

const transport = nodemailer.createTransport(mailConfig)

const viewPath = path.resolve(__dirname, '..', 'views', 'mails')

transport.use(
  'compile',
  hbs({
    viewEngine: handlebars.create({
      partialsDir: path.resolve(viewPath, 'partials')
    }),
    viewPath,
    extName: '.hbs'
  })
)

module.exports = transport

----------------------------------------------------------------------------------------------------------------
**PurchaseControlelr that uses 'Main.js'** = `class PurchaseController {
  async store(req, res) {
    const { ad, content } = req.body

    const purchaseAd = await Ad.findById(ad).populate('author')
    const user = await User.findById(req.userId)

    await Mail.sendMail({
      from: '"Wennlys Oliveira" <wennlys@gmail.com>',
      to: purchaseAd.author.email,
      subject: `Purchase solicitation: ${purchaseAd.title}`,
      template: 'purchase',
      context: { user, content, ad: purchaseAd }
    })

    return res.send()
  }
}



This seems to be an issue with handlebars itself.