【发布时间】:2015-11-24 22:25:30
【问题描述】:
我正在 Meteor 中构建一个应用程序,并尝试从服务器端方法发送电子邮件。电子邮件的模板存在于我的 client/views 文件夹中。因此,当我尝试从服务器端代码发送电子邮件时,我收到错误“模板未定义”。这是我的代码:
/server/methods/sendemail.js
var html = Blaze.toHTMLWithData(Template.emailToCustomer, dataContext);
Meteor.call('sendEmail',
thisUser.emails[0].address,
'mine@mine.org',
'yours@gmail.com',
'email subject',
html
);
我的电子邮件模板只是一个简单的 html 页面。请注意,如果它存在于 client/views/mytemplate.js 中,则此代码可以正常工作。但是,出于技术原因,我需要从服务器端代码发送电子邮件。
我尝试将 mytemplate.html 和 mytemplate.js 文件放在 app/both 和 app/server 文件夹中,但我仍然收到模板未定义错误。
有人知道会发生什么吗?
谢谢!
【问题讨论】:
标签: javascript email templates meteor server