Skip to content

Instantly share code, notes, and snippets.

@mshustov
Created January 19, 2015 12:34
Show Gist options
  • Save mshustov/0370e219f1fb062238df to your computer and use it in GitHub Desktop.
Save mshustov/0370e219f1fb062238df to your computer and use it in GitHub Desktop.
manual send mail via smtp
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