Skip to content
This repository has been archived by the owner on Jul 21, 2022. It is now read-only.

Commit

Permalink
Fixed issue with port 25 already in use error
Browse files Browse the repository at this point in the history
  • Loading branch information
FireMario211 committed Jul 4, 2021
1 parent 4f2b88f commit 25fc5d8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
19 changes: 3 additions & 16 deletions src/modules/mailbox.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// mail server
// mail box
import { SMTPServer } from "smtp-server";
import { simpleParser } from "mailparser";
import { util } from "../util";
Expand Down Expand Up @@ -29,22 +29,9 @@ export const mailbox = {
});
}, 2000);
callback();
}
}

const server: SMTPServer = new SMTPServer({
onData(stream, session, callback) {
simpleParser(stream, {}, (e, p) => {
if (e) return util.mailLog(`err: ${e}`);
return mailbox.receiveMail(p, session, callback);
})
},
disabledCommands: ["AUTH"]
});

// server.listen keeps crashing with my firewall saying I cant run port 25, if you're facing the same issue, comment out server.listen

server.listen(config.mail.port, "0.0.0.0", () => util.mailLog("server started"));
}
// Port 25 already in use probably happens because im importing from src/modules/api/mail.ts

function errorHandler(code: number, callback): void {
switch (code) {
Expand Down
20 changes: 20 additions & 0 deletions src/modules/mailserver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// mail server
import { SMTPServer } from "smtp-server";
import { simpleParser } from "mailparser";
import { util } from "../util";
import fs from "fs";
import config from "../config.json";
import { mailbox } from "./mailbox"
const server: SMTPServer = new SMTPServer({
onData(stream, session, callback) {
simpleParser(stream, {}, (e, p) => {
if (e) return util.mailLog(`err: ${e}`);
return mailbox.receiveMail(p, session, callback);
})
},
disabledCommands: ["AUTH"]
});

// server.listen keeps crashing with my firewall saying I cant run port 25, if you're facing the same issue, comment out server.listen

server.listen(config.mail.port, "0.0.0.0", () => util.mailLog("server started"));

0 comments on commit 25fc5d8

Please sign in to comment.