将本地值传递给电子邮件模板使用Express-Mailer
我想在用户注册后发送一封感谢电子邮件,但我不知道如何将用户名传递给我的电子邮件模板。 我有以下代码:
app.mailer.send('email', { to: 'newuser@gmail.com', // REQUIRED. This can be a comma delimited string just like a normal email to field. subject: 'Test Email', // REQUIRED. user: req.body.user, // All additional properties are also passed to the template as local variables. }, function (err) { if (err) { // handle error console.log(err); res.send('There was an error sending the email'); return; } res.send('Email Sent'); });
邮件模板:
<html> <head> <title>{{subject}}</title> </head> <body> Thank you {{user}} </body> </html>
您可以将属性传递给请求。
{ to: 'newuser@gmail.com', // REQUIRED. This can be a comma delimited string just like a normal email to field. subject: 'Test Email', // REQUIRED. username: req.body.username, myVar: 'username' }
variablesmyVar
作为局部variables传递给模板
- app.post的第一个string参数是做什么的?
- 错误:未能在会话中为passport-twitterfind请求令牌
- 在Express和Passport之间检测Cookie
- 如何将护照与路由控制器结合起来?
- PassportJS – 自定义callback并将Session设置为false
- PassportJS会话混合起来
- 无法在Layer.session – ExpressJS会话中读取未定义的属性“connect.sid”
- Heroku雪松堆栈上的Node.js端口问题
- req.session.passport和req.user空,serializeUser和deserializeUser都不会被调用