Skip to content

Commit

Permalink
Added better documentation, updated changelog, added TLS option in de…
Browse files Browse the repository at this point in the history
…mo.js
  • Loading branch information
ditesh committed Feb 13, 2013
1 parent 2818877 commit 7d3c7da
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 15 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG
@@ -1,6 +1,12 @@
0.1.5 (Wed Feb 13 19:05:40 MYT 2013)

* Fixed issue #4 (thanks to [https://github.com/AVBelyy] )
* Fixed issue #3 (replaced references to hashlib with inbuilt crypto)
* Better documentation, including

0.1.4 (Tue Nov 8 11:30:36 MYT 2011): 0.1.4 (Tue Nov 8 11:30:36 MYT 2011):


* Fixed issue #1 (thanks to Nazar [http://github.com/nazar] ) * Fixed issue #1 (thanks to Nazar [https://github.com/nazar] )
* Removed unused files * Removed unused files
* Fixed demo/demo.js * Fixed demo/demo.js
* Fixed bug for non-match on multiline response when -ERR is received * Fixed bug for non-match on multiline response when -ERR is received
Expand Down
20 changes: 19 additions & 1 deletion README.md
Expand Up @@ -25,7 +25,25 @@ You have two installation options:


1. Download the source and install it yourself 1. Download the source and install it yourself


## Usage ## Quick demo

Connect to GMail's POP3 servers using the provided demo script as follows:

````bash
$ node demos/demo.js --host pop.gmail.com --port 995 --username user@gmail.com --password potato --tls on --debug on --networkdebug on
Server: '+OK Gpop ready for requests from 1.2.3.4 bh7pf61475604pab.24\r\n'
CONNECT success
Client: 'USER user@gmail.com\r\n'
Server: '+OK send PASS\r\n'
Client: 'PASS potato\r\n'
Server: '-ERR [AUTH] Username and password not accepted.\r\n'
LOGIN/PASS failed
Client: 'QUIT\r\n'
Server: '+OK Farewell.\r\n'
QUIT success
````

## Detailed Usage


node-poplib is event based. It is best to illustrate via examples: node-poplib is event based. It is best to illustrate via examples:


Expand Down
24 changes: 11 additions & 13 deletions demos/demo.js
Expand Up @@ -27,21 +27,21 @@
var util = require("util"); var util = require("util");
var POP3Client = require("../main.js"); var POP3Client = require("../main.js");
var argv = require('optimist') var argv = require('optimist')
.usage("Usage: $0 --host [host] --port [port] --username [username] --password [password] --debug [on/off] --networkdebug [on/off] --msgnumber [number]") .usage("Usage: $0 --host [host] --port [port] --username [username] --password [password] --tls [on/off] --debug [on/off] --networkdebug [on/off] --msgnumber [number]")
.demand(['username', 'password']) .demand(['username', 'password'])
.argv; .argv;


var host = argv.host || "localhost"; var host = argv.host || "localhost";
var port = argv.port || 110; var port = argv.port || 110;
var debug = argv.debug === "on" ? true : false; var debug = argv.debug === "on" ? true : false;
var enabletls = argv.tls === "on" ? true : false;
var msgnumber = argv.msgnumber; var msgnumber = argv.msgnumber;
var username = argv.username; var username = argv.username;
var password = argv.password; var password = argv.password;


var client = new POP3Client(port, host, { var client = new POP3Client(port, host, {

debug: debug,
debug: (argv.networkdebug === "on" ? true: false) enabletls: enabletls

}); });


client.on("error", function(err) { client.on("error", function(err) {
Expand Down Expand Up @@ -89,7 +89,7 @@ client.on("capa", function(status, data, rawdata) {
if (status) { if (status) {


console.log("CAPA success"); console.log("CAPA success");
if (debug) console.log(" Parsed data: " + util.inspect(data)); if (debug) console.log("Parsed data: " + util.inspect(data));
client.noop(); client.noop();


} else { } else {
Expand Down Expand Up @@ -124,7 +124,7 @@ client.on("stat", function(status, data, rawdata) {
if (status === true) { if (status === true) {


console.log("STAT success"); console.log("STAT success");
if (debug) console.log(" Parsed data: " + util.inspect(data)); if (debug) console.log("Parsed data: " + util.inspect(data));
client.list(); client.list();


} else { } else {
Expand Down Expand Up @@ -162,7 +162,7 @@ client.on("uidl", function(status, msgnumber, data, rawdata) {
if (status === true) { if (status === true) {


console.log("UIDL success"); console.log("UIDL success");
if (debug) console.log(" Parsed data: " + data); if (debug) console.log("Parsed data: " + data);
client.top(123123, 10); client.top(123123, 10);


} else { } else {
Expand All @@ -179,7 +179,7 @@ client.on("top", function(status, msgnumber, data, rawdata) {
if (status === true) { if (status === true) {


console.log("TOP success for msgnumber " + msgnumber); console.log("TOP success for msgnumber " + msgnumber);
if (debug) console.log(" Parsed data: " + data); if (debug) console.log("Parsed data: " + data);
client.retr(msgnumber); client.retr(msgnumber);


} else { } else {
Expand All @@ -195,12 +195,10 @@ client.on("retr", function(status, msgnumber, data, rawdata) {
if (status === true) { if (status === true) {


console.log("RETR success for msgnumber " + msgnumber); console.log("RETR success for msgnumber " + msgnumber);
if (debug) console.log(" Parsed data: " + data); if (debug) console.log("Parsed data: " + data);


if (msgnumber !== undefined) if (msgnumber !== undefined) client.dele(msgnumber);
client.dele(msgnumber); else client.quit();
else
client.quit();


} else { } else {


Expand Down

0 comments on commit 7d3c7da

Please sign in to comment.