Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A few changes, Removing the smtp server, see the future SMTPD project…
… by @kennethkalmer
- Loading branch information
Showing
7 changed files
with
160 additions
and
456 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
examples/config.js | ||
*.swp | ||
examples/config.js | ||
*.swp |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,49 @@ | ||
/* -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil -*- */ | ||
/*=============================================== | ||
File: example-client.js | ||
Author: Micheil Smith | ||
Description: | ||
Demonstration of the smtp library. | ||
===============================================*/ | ||
var config = require("./config"); | ||
var smtp = require("../lib/smtp"); | ||
|
||
var client = new smtp.Client(); | ||
|
||
var message = "Date: "+(new Date()).toString()+"\n\ | ||
From: Node-SMTP <"+config.from+">\n\ | ||
To: <"+config.to+"\n\ | ||
Subject: Node SMTP Works!\n\ | ||
So, It looks like node-smtp all works, which is great news!\n\ | ||
\n\ | ||
Your's Truly,\n\ | ||
SMTP Client."; | ||
|
||
client.connect(config.port, config.host).addCallback(function(){ | ||
client.mail(config.from).addCallback(function(){ | ||
client.rcpt(config.to).addCallback(function(){ | ||
client.data(message).addCallback(function(){ | ||
client.quit(); | ||
}); | ||
}); | ||
}); | ||
/*=============================================== | ||
File: example-client.js | ||
Author: Micheil Smith | ||
Description: | ||
Demonstration of the smtp library. | ||
===============================================*/ | ||
var sys = require("sys"); | ||
var start_mem = process.memoryUsage(); | ||
|
||
sys.puts(JSON.stringify(start_mem)); | ||
|
||
var config = require("./config"); | ||
var smtp = require("../lib/smtp"); | ||
|
||
var client = new smtp.Client(); | ||
|
||
var message = "Date: "+(new Date()).toString()+"\n\ | ||
From: Node-SMTP <"+config.from+">\n\ | ||
To: "+config.to+"\n\ | ||
Subject: Node SMTP Works!\n\ | ||
So, It looks like node-smtp all works, which is great news!\n\ | ||
\n\ | ||
Your's Truly,\n\ | ||
SMTP Client."; | ||
|
||
client.addListener("packetSent", function(data){ | ||
sys.puts(">>> "+data); | ||
}); | ||
|
||
client.connect(config.port, config.host).addCallback(function(){ | ||
client.mail(config.from).addCallback(function(){ | ||
client.rcpt(config.to).addCallback(function(){ | ||
client.data(message).addCallback(function(){ | ||
client.quit().addCallback(function(){ | ||
client.disconnect(); | ||
|
||
var mem = process.memoryUsage(); | ||
sys.puts(JSON.stringify(mem)); | ||
sys.puts(mem["rss"]-start_mem["rss"]); | ||
sys.puts(mem["vsize"] - start_mem["vsize"]); | ||
sys.puts(mem["heapTotal"] - start_mem["heapTotal"]); | ||
sys.puts(mem["heapUsed"] - start_mem["heapUsed"]); | ||
|
||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,54 @@ | ||
/*=============================================== | ||
File: server.js | ||
Author: Micheil Smith | ||
Description: | ||
A fake server, for use in testing. | ||
===============================================*/ | ||
|
||
var sys = require("sys"); | ||
var tcp = require("tcp"); | ||
|
||
var MockServer = function(port, host){ | ||
this.server = null; | ||
this.socket = null; | ||
this.port = port; | ||
this.host = host; | ||
|
||
this.connect(); | ||
}; | ||
|
||
MockServer.prototype.connect = function(){ | ||
var self = this; | ||
|
||
this.server = tcp.createServer(function(socket){ | ||
self.socket = socket; | ||
|
||
self.socket.setEncoding("ascii"); | ||
self.socket.addListener("connect", function () { | ||
setTimeout(function(){ | ||
self.send("hello\r\n"); | ||
}, 10); | ||
}); | ||
self.socket.addListener("receive", function (data) { | ||
self.send(data); | ||
}); | ||
self.socket.addListener("eof", function () { | ||
self.send("goodbye\r\n"); | ||
self.socket.close(); | ||
}); | ||
}).listen(self.port, self.host); | ||
}; | ||
|
||
MockServer.prototype.close = function(){ | ||
this.socket.close(); | ||
}; | ||
|
||
MockServer.prototype.send = function(data){ | ||
sys.puts(">> "+data); | ||
this.socket.send(data); | ||
}; | ||
|
||
exports.Server = function(port, host){ | ||
return new MockServer(port, host); | ||
/*=============================================== | ||
File: server.js | ||
Author: Micheil Smith | ||
Description: | ||
A fake server, for use in testing. | ||
===============================================*/ | ||
|
||
var sys = require("sys"); | ||
var tcp = require("tcp"); | ||
|
||
var MockServer = function(port, host){ | ||
this.server = null; | ||
this.socket = null; | ||
this.port = port; | ||
this.host = host; | ||
|
||
this.connect(); | ||
}; | ||
|
||
MockServer.prototype.connect = function(){ | ||
var self = this; | ||
|
||
this.server = tcp.createServer(function(socket){ | ||
self.socket = socket; | ||
|
||
self.socket.setEncoding("ascii"); | ||
self.socket.addListener("connect", function () { | ||
setTimeout(function(){ | ||
self.send("hello\r\n"); | ||
}, 10); | ||
}); | ||
self.socket.addListener("receive", function (data) { | ||
self.send(data); | ||
}); | ||
self.socket.addListener("eof", function () { | ||
self.send("goodbye\r\n"); | ||
self.socket.close(); | ||
}); | ||
}).listen(self.port, self.host); | ||
}; | ||
|
||
MockServer.prototype.close = function(){ | ||
this.socket.close(); | ||
}; | ||
|
||
MockServer.prototype.send = function(data){ | ||
sys.puts(">> "+data); | ||
this.socket.send(data); | ||
}; | ||
|
||
exports.Server = function(port, host){ | ||
return new MockServer(port, host); | ||
}; |
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
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
Oops, something went wrong.