dcparker / ruby-gmail

A Rubyesque interface to Gmail. Connect to Gmail via IMAP and manipulate emails and labels. Send email with your Gmail account via SMTP. Includes full support for parsing and generating MIME messages.
http://dcparker.github.com/ruby-gmail
790 stars 123 forks source link

IETF PARSING FAIL exception when trying to read most emails #2

Closed bjeanes closed 14 years ago

bjeanes commented 14 years ago

I suspect this has to do with your problem in README: "May not correctly read malformed MIME messages. This could possibly be corrected by having IMAP parse the MIME structure"

If this is the case, how much work will be needed to parse the MIME structure with IMAP? It'd be good to be able to read all messages that GMail itself can read.

Thanks for the great work!

dcparker commented 14 years ago

Most emails? Wow .. it's worked for all emails I've tried it on so far... Are there any you'd be willing to send me a copy of one that it can't read? (the raw body content, you can get that from .body instead of .message)

If it ends up being something that's in the spec but the parser just wasn't built right to handle it, I'll fix the parser. If it's something that goes against the spec, I'll see if it's something I can let the parser allow or not. We can't make it work for faulty messages at the expense of proper ones, after all.

dcparker commented 14 years ago

bjeanes noted in email that this is actually only failing on all messages in a particular thread. However, my gem on my end was able to parse one of those messages just fine...

Change entity.rb, line 15 to: @raw = arg.gsub(/\r\r+/, "\r").gsub(/([^\r])\n/, "\1\r\n")

and see if that fixes it.