forked from andris9/n3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pop3_server.js
67 lines (55 loc) · 2.06 KB
/
pop3_server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
var N3 = require("./n3").N3,
MessageStore = require("./messagestore").MessageStore,
server_name = "fw.node.ee";
var markdown = require("node-markdown").Markdown;
// runs after the user is successfully authenticated
MessageStore.prototype.registerHook = function(){
// Add a new message to the users inbox (MessageStore)
var curtime = new Date().toLocaleString(),
message = "Tere ÕÜÄÖŠ!\n------------------\n\n"+
"Kell on praegu **"+curtime+"**\n"+
"\n"+
"Vaata ka:\n"+
"\n"+
" * [Delfi](http://www.delfi.ee)\n" +
" * [NETI](http://www.neti.ee)\n" +
" * [EPL](http://www.epl.ee)\n" +
"\n"+
"*Koodiblokk*\n"+
"\n"+
" for(var i=0;i<100;i++){\n"+
" alert(i+5);\n"+
" }\n"+
"\n\n"+
"Parimat, \nKellamees";
this.addMessage({
toName: "Andris Reinman",
toAddress: "andris.reinman@gmail.com",
fromName: "Ämblik Kämbu",
fromAddress: "amblik.kambu@node.ee",
subject: "Muti metroo on nüüd avatud!",
text: message,
html: markdown(message)
});
}
// Currenlty any user with password "12345" will be authenticated successfully
function AuthStore(user, auth){
var password;
if(user){
password = 12345;
}
return auth(password);
}
// Setup servers for both port 110 (standard) and 995 (secure)
// listen on standard port 110
N3.startServer(110, server_name, AuthStore, MessageStore);
// Custom authentication method: FOOBAR <user> <pass>
N3.extendAUTH("FOOBAR",function(authObj){
var params = authObj.params.split(" "),
user = params[0],
pass = params[1];
if(!user) // username is not set
return "-ERR Authentication error. FOOBAR expects <user> <password>"
authObj.user = user;
return authObj.check(user, pass);
});