【问题标题】:Parse-Server-Mailgun : How to edit templates and have them pushed to serverParse-Server-Mailgun : 如何编辑模板并将它们推送到服务器
【发布时间】:2017-02-07 21:15:21
【问题描述】:
这是对我之前问题的扩展:
Setup mailgun with parse-server on Heroku
当您运行“$ npm install parse-server-mailgun”时,它会在我的当前目录中安装一堆目录和文件。但是,当我编辑其中任何一个,特别是电子邮件模板或任何不在我的 parse-server-example 文件夹的主根目录中的东西时,它们不会推送到 Heroku。
我假设,如果是这种情况,它必须只是推送位于根目录中的主要配置文件,然后从某个地方的 nom 中提取其余部分?
如何将整个目录及其所有子文件夹/文件推送到我的 Heroku 服务器?还是编辑服务器上已有的电子邮件模板?
抱歉,这个问题可能有点愚蠢。
【问题讨论】:
标签:
heroku
parse-platform
parse-server
mailgun
【解决方案1】:
您不应修改包文件夹中的模板。相反,在项目目录中创建自己的模板,然后在初始化 ParseServer 时引用这些模板。然后只需将这些新文件添加到您的 git 存储库中,它们就会在服务器上可用。
例如:
emailAdapter: {
module: 'parse-server-mailgun',
options: {
// The address that your emails come from
fromAddress: 'Hello <hello@example.com>',
// Your domain from mailgun.com
domain: config.Mailgun.domain,
// Your API key from mailgun.com
apiKey: config.Mailgun.api,
templates: {
verificationEmail: {
subject: 'Please verify your e-mail for Example.com',
pathPlainText: './email/emailVerification/index.txt',
pathHtml: './email/emailVerification/index.html',
callback: function (user) { return { firstName: user.get('firstName') }; }
// Now you can use {{firstName}} in your templates
}
}
}
}
【解决方案2】:
简单的修复。将它们放在构建的根目录中。它们将自动提交到他的服务器
【解决方案3】:
你可以使用这个mail adapter,它真的很容易使用,你也可以用它来发送多语言邮件。
希望对您有所帮助。 ??
一个如何使用它的小例子。
emailAdapter: {
module: 'parse-smtp-template',
options: {
...
template: true,
templatePath: "views/templates/template.html",
// Custome options to your emails
// You can add more options if you need
passwordOptions: {
subject: "Password recovery",
body: "Custome pasword recovery email body",
btn: "Recover your password"
/* --EXTRA PARAMETERS--
others: {
extraParameter
}
*/
},
confirmOptions: {
subject: "E-mail confirmation",
body: "Custome email confirmation body",
btn: "confirm your email"
},
}
}
https://github.com/macarthuror/parse-smtp-template