Go back to the main page

MMS2R Invalid Byte Sequence in UTF-8

This article is over 2 years old. Proceed with caution.

Regards ♨ – Minimul

 

Incoming email

Simplton's email interface is vital to certain users and is the only way they interact with the app. Incoming email since '08 has been powered by the wonderful MMS2R by Mike Mondragon. If you are looking for an email parser that handles mms and regular email go for MMS2R. Shortly after upgrading Simplton to Ruby 1.9 and Rails 3.1 I started getting the following error on some incoming emails.

invalid byte sequence in UTF-8
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/mail-2.3.0/lib/mail/core_extensions/string.rb:12:in `=~'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/mail-2.3.0/lib/mail/core_extensions/string.rb:12:in `!~'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/mail-2.3.0/lib/mail/core_extensions/string.rb:12:in `blank?'
/usr/local/rvm/gems/ruby-1.9.2-p290/gems/mms2r-3.5.1/lib/mms2r/media.rb:269:in `body'

The emails in question were coming from a desktop and Android outlook client (or perhaps a generic mail client).

Fix

Mike got on this immediately and there is a fix in MMS2R 3.6. If your Gemfile has gem "mms2r" simply do a bundle update.

More info

  • See the patch (look down to the commit in the lib/mms2r/media.rb file).
  • If you are getting this error in a different context still look at Mike's patch above but also this article may be helpful.
Comment on this article?