Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with mailgun routed data? #487

Closed
nihalsharma opened this issue Sep 2, 2015 · 4 comments
Closed

Issue with mailgun routed data? #487

nihalsharma opened this issue Sep 2, 2015 · 4 comments
Labels

Comments

@nihalsharma
Copy link

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!

@asvetlov
Copy link
Member

asvetlov commented Sep 2, 2015

Hi. I don't familiar with mailgun api but aiohttp test suite has cases for multiple file uploading:
test_files_upload_with_same_key and test_post_files. How the tests are different from your case?

@nihalsharma
Copy link
Author

I have mailed you with the post data that I receive on my api. Please have a look. There must be something which Mailgun is sending which is out of convention.

@nihalsharma
Copy link
Author

I applied this patch and things worked fine. https://bugs.python.org/issue24764.

Please see if any thing needs to be added on your end. Thanks

@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants