[email] Use envelope recipient address instead of To:
This commit is contained in:
parent
4b50157e54
commit
88af3e8204
|
@ -9,11 +9,17 @@ import requests
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from kibicara.platforms.email.model import Email
|
from kibicara.platforms.email.model import Email
|
||||||
from kibicara.model import Hood
|
from kibicara.model import Hood
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
logger = getLogger(__name__)
|
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
|
# read mail from STDIN
|
||||||
mailbytes = bytes(sys.stdin.read())
|
mailbytes = bytes(sys.stdin.read())
|
||||||
|
|
||||||
|
@ -33,8 +39,8 @@ def main():
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.info("No Body in this message part", exc_info=True)
|
logger.info("No Body in this message part", exc_info=True)
|
||||||
exit(0)
|
exit(0)
|
||||||
to = mail['To'].lower()
|
# extract hood name from the envelope recipient address
|
||||||
hood_name = to.split('@')[0]
|
hood_name = args.recipient_address.split('@')[0]
|
||||||
hood = await Hood.objects.get(name=hood_name)
|
hood = await Hood.objects.get(name=hood_name)
|
||||||
body = {
|
body = {
|
||||||
'text': text,
|
'text': text,
|
||||||
|
|
Loading…
Reference in a new issue