Skip to content

Avoid repeat Content-Transfer-Encoding#55

Closed
destanyol wants to merge 5 commits intogisce:masterfrom
Som-Energia:base64_mimetype_repeated
Closed

Avoid repeat Content-Transfer-Encoding#55
destanyol wants to merge 5 commits intogisce:masterfrom
Som-Energia:base64_mimetype_repeated

Conversation

@destanyol
Copy link
Contributor

We noticed that the shared inbox e-mail client we are using has trouble with some repeated headers of the attachment.

In particular it has trouble with the "Content-Transfer-Encoding" header. Qreu sends it two times like this:

--===============6391006585805361748==
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Type: application/pdf; charset="utf-8"
Content-Disposition: attachment; filename="file.pdf"
Content-Transfer-Encoding: base64

JVBERi0xLjQKMSAwIG9iago8P...

By default when you create the attachment as a MIMEApplication the Content-Transfer-Encoding header is added by default and also by default is base64, so the Content-Transfer-Encoding doesn't have to be added manually afterwards.

But, because "Explicit is better than implicit" in this Pull Request I have hardcoded the _encoder to base64 so the change is more clear for the reviewer.

The result with the new changes are:

--===============5362653904239654853==
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Type: application/pdf; charset="utf-8"
Content-Disposition: attachment; filename="file.pdf"

JVBERi0xLjQKMSAwIG9iago8P...

@destanyol
Copy link
Contributor Author

Closed, new PR in #65

@destanyol destanyol closed this Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants