The gem splits multipart emails on a boundary string using a Regex, but this fails on certain invalid emails when the boundary is interpreted as UTF-8 and the body is considered ASCII-8BIT, causing an exception:
Encoding::CompatibilityError: incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string)
I changed it to detect that case and simply force the encoding of boundary to ASCII-8BIT so it can work without exception. Not sure if it should do something smarter, but this seems to at least work for the tiny fraction of emails that have this problem.
The gem splits multipart emails on a boundary string using a Regex, but this fails on certain invalid emails when the boundary is interpreted as UTF-8 and the body is considered ASCII-8BIT, causing an exception:
I changed it to detect that case and simply force the encoding of boundary to ASCII-8BIT so it can work without exception. Not sure if it should do something smarter, but this seems to at least work for the tiny fraction of emails that have this problem.