From 88af3e8204d7376bc761ad406728b57b7812eacc Mon Sep 17 00:00:00 2001 From: maike Date: Mon, 6 Jul 2020 22:15:38 +0200 Subject: [PATCH] [email] Use envelope recipient address instead of To: --- kibicara/kibicara_mda.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kibicara/kibicara_mda.py b/kibicara/kibicara_mda.py index 40a0184..ccaa018 100644 --- a/kibicara/kibicara_mda.py +++ b/kibicara/kibicara_mda.py @@ -9,11 +9,17 @@ import requests from logging import getLogger from kibicara.platforms.email.model import Email from kibicara.model import Hood +import argparse def main(): logger = getLogger(__name__) + # the MDA passes the recipient address as command line argument + parser = argparse.ArgumentParser() + parser.add_argument("recipient_address") + args = parser.parse_args() + # read mail from STDIN mailbytes = bytes(sys.stdin.read()) @@ -33,8 +39,8 @@ def main(): except Exception: logger.info("No Body in this message part", exc_info=True) exit(0) - to = mail['To'].lower() - hood_name = to.split('@')[0] + # extract hood name from the envelope recipient address + hood_name = args.recipient_address.split('@')[0] hood = await Hood.objects.get(name=hood_name) body = { 'text': text,