This commit is contained in:
Leandro Facchinetti 2020-03-22 08:33:16 -04:00
parent b6dabd2386
commit d984e361f5
1 changed files with 31 additions and 29 deletions

View File

@ -39,7 +39,8 @@ export const webServer = express()
export const emailServer = new SMTPServer({ export const emailServer = new SMTPServer({
disabledCommands: ["AUTH", "STARTTLS"], disabledCommands: ["AUTH", "STARTTLS"],
async onData(stream, session, callback) { onData(stream, session, callback) {
(async () => {
const paths = session.envelope.rcptTo.flatMap(({ address }) => { const paths = session.envelope.rcptTo.flatMap(({ address }) => {
const match = address.match(/^(\w+)@kill-the-newsletter.com$/); const match = address.match(/^(\w+)@kill-the-newsletter.com$/);
if (match === null) return []; if (match === null) return [];
@ -68,6 +69,7 @@ export const emailServer = new SMTPServer({
fs.writeFileSync(path, renderXML(xml)); fs.writeFileSync(path, renderXML(xml));
} }
callback(); callback();
})().catch(callback);
} }
}).listen(process.env.NODE_ENV === "production" ? 25 : 2525); }).listen(process.env.NODE_ENV === "production" ? 25 : 2525);