Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown command on Gmail gem

Tags:

ruby

gmail

I'm trying to get my emails using the Gmail gem (source) with the next call:

class MyClass
  def initialize account, credentials
    @gmail = Gmail.connect(account, credentials)
  end

  def get_attachments received_at, options
    mails = @gmail.inbox.find(
      :to => options[:to],
      :has=>:attachments,
      :before => options[:end_date],
      :after => received_at
     )
     #more code
   end
end

@gmail is a valid instance of Gmail class, and this call raises sometimes the next error:

Unknown command v2if4084974eef.9

The command (v2if4084974eef.9) changes in every call I make.

What am I doing wrong?

[Edit]

The error raised in specs is this

1)
Net::IMAP::BadResponseError in 'MailFacade get_data should return an array'
Unknown command v17if3069084anm.44
like image 941
pablorc Avatar asked Nov 01 '25 07:11

pablorc


1 Answers

I had this issue and I found the answer to this in the last comment on this link:

https://github.com/nu7hatch/gmail/issues/36

You just have to follow these steps: 1. Go to your Google account settings: myaccount.google.com 2. Click on "connected apps & sites" option. 3. Turn "Allow less secure apps" to "ON" (near the bottom of the page).

That's it, at least works for me, hope it works for you aswell.

Greetings from Bolivia!!

like image 121
xXAngelJinXx Avatar answered Nov 04 '25 05:11

xXAngelJinXx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!