-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
24 lines (22 loc) · 707 Bytes
/
index.js
File metadata and controls
24 lines (22 loc) · 707 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const {SMTPServer} = require('smtp-server');
const fs = require('fs').promises;
const server = new SMTPServer({
// disable STARTTLS to allow authentication in clear text mode
disabledCommands: ['STARTTLS', 'AUTH'],
logger: true,
onData(stream, session, callback) {
let buffer = "";
stream.pipe(process.stdout); // print message to console
stream.on('data', (chunk) => {
buffer += chunk;
});
stream.on('end', err => {
const ts = Date.now();
const name = `email_${ts}`;
fs.writeFile(`./${name}.eml`, buffer);
buffer = "";
callback(err);
});
},
});
server.listen(456);