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
792 stars 123 forks source link

Wrong format in to_imap_date method #89

Closed nimdraugsael closed 7 years ago

nimdraugsael commented 8 years ago

Yesterday I started getting Net::IMAP::BadResponseError: Could not parse command when used before and after params for inbox.

Date format in IMAP spec https://tools.ietf.org/html/rfc3501 page 83

date-month      = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" /
                  "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec"

So, it should be

class Object
  def to_imap_date
    Date.parse(to_s).strftime("%d-%b-%Y")
  end
end

in https://github.com/dcparker/ruby-gmail/blob/master/lib/gmail/mailbox.rb#L5

richardrails commented 8 years ago

+1

rickumali commented 8 years ago

I have a script that uses ruby-gmail that runs every month. Last month (Sept 2016) it worked, this month (Oct 2016), it spit out:

$HOME/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/net/imap.rb:1158:in `get_tagged_response': 
    Could not parse command (Net::IMAP::BadResponseError)
        from $HOME/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/net/imap.rb:1210:in 
            `block in send_command'

My script uses the before and after params to gmail.inbox.emails().each.

I applied the one character patch from @nimdraugsael and now the script works again!

nimdraugsael commented 8 years ago

Hey, any maintainers here? :)

jasonjei commented 8 years ago

@nimdraugsael The maintainer had passed away a few years ago...