使用emailjs添加电子邮件模板
我有以下几行,这是我试过的,它工作正常,但我想加载一个模板来绘制内容,我怎样才能附加一个文件作为电子邮件的内容显示? 这里有我所拥有的:
attachment:[{data: req.__({ phrase: 'Please click this link to reset your password: https://website.com/reset/%s', locale: locale}, user.uuid), alternative:true}]
我怎样才能加载一个path来读取像HTML文件的内容?
我可以使用添加以下行的模板:
var forgotTemplate = fs.readFileSync('../public/mailplates/forgot');
接着:
attachment: [{data: forgotTemplate, alternative:true}]
无论如何,我需要适应“哈希”更改密码,我怎么可以添加脚本行内部或至less一个string?
var email = require("./path/to/emailjs/email"); var server = email.server.connect({ user: "username", password:"password", host: "smtp.your-email.com", ssl: true }); var message = { text: "... ", from: "...", to: "...", subject: "testing emailjs", attachment: [ {data:"<html>i <i>hope</i> this helps</html>", alternative:true}, {path:"path/to/file.zip", type:"application/zip", name:"renamed.zip"} ] }; // send the message and get a callback with an error or details of the message that was sent server.send(message, function(err, message) { console.log(err || message); });
最后, 解决scheme是与玉,我补充说:
var jade = require('jade');
接着:
var forgotTemplate = jade.renderFile('../public/mailplates/forgot.jade', {userRecover: userInfoRecover});
Jade模板必须显示如下所示:
doctype html html head title = forgot password body h1 this works a(href='#{ userRecover }') link
- Javascript对象值的和数组
- 检查用户是否已经存在(Node.js和mysql)
- Google Calendar API v3推送通知不尊重timeMax或timeMin
- 模块构build失败:错误:AotPlugin被检测到,但是它是一个错误类的实例
- 如何从一个函数中检索并传递来自多个Schema的数据
- 如何在Ubuntu下安装bower? 节点已成功安装
- 使用REST API时,Meteor是否保留react native?
- Nodejs返回Blockchain Rates API的完整JSON,但是我不能访问它里面的特定对象。 为什么?
- 为什么node.js querysting模块应该将plus(+)转换为空格?