Created
January 19, 2015 12:34
-
-
Save mshustov/0370e219f1fb062238df to your computer and use it in GitHub Desktop.
manual send mail via smtp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var promise = require('promise'); | |
var punycode = require('./punycode.min'); | |
var smtpc = require("smtpc"); | |
var config = require("./config"); | |
exports.send_mail = function (to, topic, body) { | |
return new promise(function(resolve, reject){ | |
var _to = []; | |
for (var i = 0 ; i < to.length; i++) { | |
_to[i] = punycode.toASCII(to[i]); | |
} | |
smtpc.sendmail({ | |
"host": config.mail_host, | |
"from": "devnull@yandex.ru", | |
"to": _to, | |
"content": { | |
"from": "=?utf-8?B?0K/QvdC00LXQutGB?= <devnull@yandex.ru>", | |
"to": _to, | |
"subject": topic, | |
"content-type": "text/html", | |
"content": body | |
}, | |
"success": function () { | |
resolve(); | |
}, | |
"failure": function (err) { | |
console.log("message NOT sent! Topic", topic, '\nbody\n', body); | |
console.log("Error(%d): %s", err.code, err.message); | |
} | |
}); | |
}); | |
}; | |
exports.render = function (card) { | |
var result = 'пущь пущь!!!'; | |
return result; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment