-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
33 lines (27 loc) · 868 Bytes
/
app.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
const express = require("express");
const app = express();
const { error } = require("console");
const SMTPServer = require("smtp-server").SMTPServer;
const PORT = 25;
const server = new SMTPServer({
allowInsecureAuth: true,
authOptional: true,
onConnect(session, cb){
// cb(new error('Cannot accept connection'))
console.log(`onConnect`, session.id);
cb()//accept the connection
},
onMailFrom(address, session, cb){
console.log(`onMailFrom`, address.address, session.id);
cb();
},
onRcptTo(address, session, cb){
console.log(`OnRcptTo`, address.address, session.id);
cb();
},
onData(stream, session, cb){
stream.on('data', (data) => console.log(`onData ${data.toString()}`));
stream.on('end', cb)
}
});
server.listen(PORT, ()=> console.log(`Server running on port ${PORT}`));