-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
TypeError for SafeMIMEText #148
Comments
Please take a look at this Github gist. I am reproducing the Python code here. Run the code with Django version 1.11 and Python 3.6. I think the behavior should be the same for other versions as well. The summary is that Postmarker crashes when sending an email with a HTML alternative as well as an attachment. Sending a mail with a HTML alternative alone works. Send a mail with an attachment alone works. There is also a different issue. Sending a
|
Regarding plain text attachment. You have to pass base64 encoded content: From the docs
Regarding the second issue - I'll take a look tomorrow Thank you for reporting the problem :) |
Probably, a validation for base64 string could be added. What do you think? |
The issue is in postmarker/postmarker/models/emails.py Line 80 in 62cc043
|
I am a bit confused. Is the base64 encoding needed only for text/plain or for other types as well? I have sent PDF attachments by providing the raw content without any encoding. Also, the base64 encoding could be a requirement for a low level API. However, it should not be required when sending emails from Django. (I don't need to send text attachments. I came across this issue while debugging the other TypeError issue). When sending from Django, the API to the user should be unchanged. The user should simply have to change their backend and the code should work. Any base-64 encoding should be performed by the postmarker library and not by the user. |
The following patch seems to work for me. I don't know enough details to know if I am doing the right thing.
|
* Handle emails with HTML alternatives and attachments Fixes issue #148 * Fix lint
Btw, regarding base64 - Django automatically encodes content in base64, that's why it was possible to send pdf without an error. I'll make a change in postmarker to automatically encode data in base64 in similar way, but, probably it will be controlled by some kwarg, will see. |
I don't know yet :( |
I'll create a separate issue for base64 encoding |
Follow up for this comment:
Hi @suriya !
Could you, please, add some code to reproduce the issue?
The text was updated successfully, but these errors were encountered: