Closed asiniy closed 9 years ago
@asiniy I've seen this as well. IMHO since this is the response coming from Gmail, and I think it actually is coming from the raw mail sender, we shouldn't fix this within the gem. What do you think?
I think we can use .gsub(/=\r\n/, '')
for retrieved content. Anyways anyone who working with gmail should implement this method to get successful result.
Actually I just see \r\n
, I don't think I've see =
char...
Hello @asiniy @johnnyshields
I have tried this
email = @gmail_account.mailbox(label.name).find(:unread).first
email.message.html_part.body.raw_source
The result for my unread mailbox is not nil value i.e email
is not nil.
but I got error undefined method body for nil:NilClass
because I got nil
value as result of email.message.html_part
.
Then I tried email.message.to_s
then I got the result that you get, that is I see \r\n
, but can't see =
character in the result.
Can you tell me why the html_part
gives nil
result?
@amoludage so firstly it seems you and I are seeing the same thing (\r\n without =)
Re: html_part
, my understanding is that this is only populated are you using a [http://guides.rubyonrails.org/action_mailer_basics.html#sending-multipart-emails](multipart email) which includes an HTML component.
Please also note that the email.message
class uses https://github.com/mikel/mail you may want to look there for answers.
@johnnyshields Thanks,
I'm not using http://guides.rubyonrails.org/action_mailer_basics.html#sending-multipart-emails but I'll look into https://github.com/mikel/mail and let you know.
@asiniy I'm inclined to close this issue because it looks like these chars are part of normal email format according to http://www.faqs.org/rfcs/rfc2822.html (see section 2.1, \r\n
is referred to as CRLF). You'd probably want to preserve them if you are resending messages; I agree it's a pain when reading the text but it's not the job of Gmail gem to handle them. If you don't want this behavior you can filter it out in your app or monkey patch the Mail::Message
class somehow.
Hey!
I want to fetch html code of incoming gmail messages to parse via nokogiri gem. That's how I use it:
I got a lot of annoying
=\r\n
in my html. Of course, I can remove it using.gsub(/=\r\n/, '')
, but this seems to be a bad way. Is there any simpler way to solve my issue?