Skip to content

Instantly share code, notes, and snippets.

@sdb
Created April 29, 2012 16:03
Show Gist options
  • Save sdb/2551556 to your computer and use it in GitHub Desktop.
Save sdb/2551556 to your computer and use it in GitHub Desktop.
Simple debugging SMTP server with Node.js
node_modules

Simple debugging SMTP server with Node.js. Messages will be discarded, and printed on the console.

Usage

Clone this gist:

git clone git://gist.github.com/2551556.git node-smtp-debug
cd node-smtp-debug

Install simplesmtp package:

npm install simplesmtp

Run the script:

sudo node server.js
var simplesmtp = require("simplesmtp");
var client = simplesmtp.connect(25);
client.once("idle", function(){
client.useEnvelope({
from: "me@localhost.com",
to: ["receiver1@localhost.com", "receiver2@localhost.com"]
});
});
client.on("message", function(){
client.write('blabla');
client.end();
});
client.on("ready", function(success, response){
if(success){
console.log("The message was transmitted successfully with "+response);
}
client.quit();
});
var simplesmtp = require("simplesmtp");
var smtp = simplesmtp.createServer({debug:true, enableAuthentication:true});
smtp.listen(25, function(err) {
if (err) console.log(err);
});
smtp.on("authorizeUser", function(envelope, username, password, callback){
callback(null, true)
});
smtp.on("dataReady", function(envelope, callback){
callback(null, "ABC1"); // ABC1 is the queue id to be advertised to the client
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment