我正在为nodemailer公司的项目使用它,它的运行非常完美 精细。
我想知道是否有可能从发布请求中自动获取用户信息。例如,我需要像这样获取html变量:
html:“您好,我是${request.username}
,我已将此电子邮件发送给您”
这就是我需要我的请求的样子:
var transporter = nodemailer.createTransport({
host: 'servername.com',
port: 25,
debug: true,
logger:true,
secure: false,
});
// i need the mail options like the following
var mailOptions = {
from: 'MYEMAIL@COMPANYNAME.com', // sender address (who sends)
to: 'MYEMAIL@COMPANYNAME.com', // list of receivers (who receives)
subject: 'this email sent from ${request.username} ', // Subject line
text: 'Hello world ', // plaintext body
html: 'this email sent from ${request.username}'
};
// send mail with defined transport object
transporter.sendMail(mailOptions, function(error, info){
if(error){
return console.log(error);
}
答案 0 :(得分:0)
除非您有可用的用户名和电子邮件映射,否则您无法(在道德上)问什么。但是,仍然要在电子邮件中添加个人风格,您可以在“ @”之前使用部分,例如,以该电子邮件为“ your_name@domain.com”,您可以将电子邮件发送为 $ {request.username}将是“您的名字”