我使用 sails 创建了一个名为 JoinUs 的 API。我想要的是在创建新寄存器之前/之后发送一封电子邮件。 (使用蓝图加入/创建)
我正在使用 Node 机器代码通过 mailgun 发送电子邮件。但是,当我在 JoinUs Controller (操作创建)中编写此代码时,它似乎不起作用。我有正确的 mailgun 凭据。
有什么想法吗?
/**
* JoinUsController
*
* @description :: Server-side logic for managing joinuses
* @help :: See http://sailsjs.org/#!/documentation/concepts/Controllers
*/
module.exports = {
create: function (res, req){
var Mailgun = require('machinepack-mailgun');
// Send an html email.
Mailgun.sendHtmlEmail({
apiKey: 'key-Xxxxxxxxxxxx',
domain: 'domain.com',
toEmail: 'dev@gmail.com',
toName: 'DEV',
subject: 'Welcome!',
textMessage: 'Jane,\nThanks for joining our community. If you have any questions, please don\'t hesitate to send them our way. Feel free to reply to this email directly.\n\nSincerely,\nThe Management',
htmlMessage: 'Jane,\nThanks for joining our community. If you have any questions, please don\'t hesitate to send them our way. Feel free to reply to this email directly.\n\nSincerely,\nThe Management',
fromEmail: 'harold@example.enterprise',
fromName: 'Harold Greaseworthy',
}).exec({
// An unexpected error occurred.
error: function (err){
},
// OK.
success: function (){
},
});
}
};
最佳答案
看看这个@DevArtisan Sails Email Service
希望对你有帮助!
关于javascript - 无法使用 Sails.js 和 Node 机器 mailgun 发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35009013/