-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (26 loc) · 919 Bytes
/
index.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
const SMTPServer = require("smtp-server").SMTPServer;
const server = new SMTPServer({
allowInsecureAuth: true,
authOptional: true,
onConnect(session, cb) {
console.log(`onConnect `, session.id)
cb() // accepting the connection
// cb (new Error('cannot accept)) if we dont want to 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()}`)
})// when the stream of data is coming
stream.on('end', cb) // when the stream of data is ended
cb()
},
});
server.listen(25, () => console.log('Server Running on Port 25'))