-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Issue with mailgun routed data? #487
Description
I am using aiohttp. I have an api which handles Mailgun routed data. The emails have multiple attachments. I am not able to read all of the attachments. It just gives me a single one.
data is what I receive.
str(list(data.keys())) gives me the list -
['Content-Type', 'Date', 'Dkim-Signature', 'From', 'Message-Id', 'Mime-Version', 'Received', 'Received', 'Received', 'Subject', 'To', 'X-Envelope-From', 'X-Mailgun-Incoming', 'X-Received', 'attachment-count', 'body-html', 'body-plain', 'from', 'message-headers', 'recipient', 'sender', 'signature', 'stripped-html', 'stripped-signature', 'stripped-text', 'subject', 'timestamp', 'token', 'attachment-1']
str(data.get('attachment-count') gives me 2/3/4 when I send multiple files in the email - which is fine. But there is only one key as attachment-1. There should be 'attachment-1' and 'attachment-2' and so on.
I tried running a flask server and tested emails with multiple files:
print(request.files) prints ImmutableMultiDict([('attachment-2', <FileStorage: 'Screen Shot 2015-09-02 at 10.18.37 am.png' ('image/png')>), ('attachment-1', <FileStorage: 'Screen Shot 2015-09-02 at 10.18.36 am.png' ('image/png')>)])
which shows there are two files indeed.
Now there is certainly an issue with how aiohttp is handling the mailgun's data:
printing request.post() gives only one file - 'attachment-1': Field(name='attachment-1', filename='Screen Shot 2015-09-02 at 10.40.18 am.png', file=<_io.BufferedRandom name=10>, content_type='image/png'). There is no attachment-2, god knows why!