From 9c4ea7a4344bd467461f3d781d5a70bc91e8bc42 Mon Sep 17 00:00:00 2001 From: Leandro Facchinetti Date: Sun, 14 Mar 2021 23:02:38 +0000 Subject: [PATCH] --- src/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 111b59c..c043e1c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -447,7 +447,6 @@ export default function killTheNewsletter( disabledCommands: ["AUTH", "STARTTLS"], async onData(stream, session, callback) { try { - const atHost = "@" + new URL(webApplication.get("email")).hostname; const email = await mailparser.simpleParser(stream); const from = email.from?.text ?? ""; const subject = email.subject ?? ""; @@ -459,8 +458,11 @@ export default function killTheNewsletter( (smtpServerAddress) => smtpServerAddress.address ) )) { - if (!address.endsWith(atHost)) continue; - const feedReference = address.slice(0, -atHost.length); + const addressParts = address.split("@"); + if (addressParts.length !== 2) continue; + const [feedReference, hostname] = addressParts; + if (hostname !== new URL(webApplication.get("email")).hostname) + continue; const feed = database.get<{ id: number }>( sql`SELECT "id" FROM "feeds" WHERE "reference" = ${feedReference}` );