Created
July 8, 2015 14:15
-
-
Save rahul-desai3/c75886bb84eeb5d84c1c to your computer and use it in GitHub Desktop.
How do I call this plugin to send emails?
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 outbound = require('./outbound'); | |
exports.hook_data = function (next, connection) { | |
this.loginfo("in hook data"); | |
next(); | |
} | |
exports.hook_data_post = function (next, connection) { | |
this.loginfo("in hook data post"); | |
next(); | |
} | |
exports.hook_queue = function (next, connection) { | |
var plugin = this; | |
var to = 'test2@myserver.com'; | |
var from = 'test@myserver.com'; | |
var contents = [ | |
"From: test@myserver.com", | |
"To: test2@myserver.com", | |
"MIME-Version: 1.0", | |
"Content-type: text/plain; charset=us-ascii", | |
"Subject: Some subject here", | |
"", | |
"Some email body here", | |
""].join("\n"); | |
var outnext = function (code, msg) { | |
switch (code) { | |
case DENY: plugin.logerror("Sending mail failed: " + msg); | |
break; | |
case OK: plugin.loginfo("mail sent"); | |
next(); | |
break; | |
default: plugin.logerror("Unrecognised return code from sending email: " + msg); | |
next(); | |
} | |
}; | |
outbound.send_email(from, to, contents, outnext); | |
} | |
exports.hook_rcpt = function (next, connection, params) { | |
this.loginfo("in hook receipt"); | |
next(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment