[英]Can't send email with Sails.js and node-machine mailgun
我已經用帆創建了一個名為JoinUs的API。 我想要的是在創建新注冊之前/之后發送電子郵件。 ( 加入/使用藍圖創建 )
我正在使用節點機器代碼通過mailgun發送電子郵件。 但是,當我在JoinUs控制器(動作創建)中編寫此代碼時,似乎無法正常工作。 我有正確的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電子郵件服務
希望能幫助到你!
謝謝。
我可以發送電子郵件,但是無法在數據庫中創建記錄。 我所做的是將創建控制器重寫為上面的代碼,但我不知道這是否會影響。 或者,在創建數據庫記錄時,如何發送電子郵件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.