-
-
Notifications
You must be signed in to change notification settings - Fork 373
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
Multipart content sent as base64 with ContentEncoding set to Default #721
Comments
Default just means "no encoding specified". When you call MimeMessage.Prepare() (or when MailKits SmtpClient calls it for you) it will check those unencoded MimeParts to make sure they won't break SMTP rules and force an encoding if they do (think: long lines > 998 characters, nil characters, 8bit characters, etc) Also worth noting is that some SMTP servers will reencode parts so the receiving client really needs to be fixed to handle that. |
I see. |
You can set the ContentTransferEncoding to ContentEncoding.SevenBit or EightBit (as appropriate). Setting EightBit is safe to use even when the content is ascii. |
Unfortunately, that did not appear to fix the issue at hand, so I am forced to stay with the older version. |
I took a closer look and SmtpClient calls SmtpClient.Prepare() (which you can override). The default implementation calls MimeMessage.Prepare(). MimeMessage.Prepare() iterates over all body parts calling Prepare() on them. MimePart.Prepare() no-ops only if the ContentTransferEncoding property is set to Base64, QuotedPrintable, or UUEncode. It will also no-op if set to Binary, but only if the EncodingConstraint is None. In all other cases, it calculates the best encoding to use for the provided EncodingConstraint. TL;DR you can override SmtpClient.Prepare() to make it no-op and that should resolve your issue. |
But the code isn't using SmtpClient |
Oh, are you calling MimeMessage.Prepare()? |
The code creates a MultipartRelated instance, puts a few MimePart objects into it, each with some xml content. |
Thanks for the details. Signing a MimeEntity forces MimeKit to enforce the same encoding rules that Prepare() enforces because the assumption is that the message or entity will be transmitted over SMTP. Sounds like this assumption, at least in your case, is not the case. |
I'm reopening because maybe I can figure out a solution that will allow overriding that behavior such that it works for your needs as well as typical mail (i.e. SMTP) needs. One possibility is to have a MultipartSigned.Create() method that takes a |
MimeKit v3.0.0 has been released with this feature. |
Describe the bug
I upgraded MimeKit from 2.1.3 to 2.15.1 in a solution implementing RosettaNet, after this receipts were no longer coming from the partner receiving the messages.
It turns out that they had started receiving base64 rather than xml, which was not supported.
The parts of the message are defined like this;
According to ContentEncoding, the Default value should not encode at all, so base64 is unexpected.
Platform (please complete the following information):
Expected behavior
Mime parts to be delivered unencoded
The text was updated successfully, but these errors were encountered: