1

I am getting this error when trying to set the deleted flag;

Net::IMAP::NoResponseError (STORE attempt on READ-ONLY folder (Failure))

The error is thrown when running this;

connector.uid_store(item_uid, "+FLAGS", [:Deleted])

This code runs fine just before it;

connector.create("TestFolder") unless connector.list('', "TestFolder")
connector.uid_copy(item_uid, "TestFolder")

I have not been able to find a reason for this, especially since I can create 'folders' and copy items to it without a problem. I am using ruby 1.9.2, rails 3.2.10, mail 2.4.4

Any help would really save my mind.

Cheers

~~~~~~~ edit Mail defaults are setup as per below;

#==> Collect items
case feed.url_type
when "IMAP"
  puts "Trying IMAP retriever for " + feed.url_source
  Mail.defaults do
    retriever_method :imap,
      :address => feed.url_source,
      :port => 993,
      :user_name => feed.user,
      :password => feed.password,
      :enable_ssl => true,
      :read_only => false
  end
  self.add_email_stubs(Mail.find(), feed)

The connector is picked up from here;

def add_email_stubs(items, feed)
    Mail.all do |item, connector, item_uid|

and used here (in same def);

  #==> Move message
  connector.create("Archive") unless connector.list('', "Archive")
  connector.uid_copy(item_uid, "Archive")
  connector.uid_store(item_uid, "+FLAGS", [:Deleted])  <==Error occurs here
Cy Walker
  • 41
  • 5
  • How do you set up `connector`? If you are by any chance using `examine`, that sets up read-only access to the folder. – eugen Feb 04 '13 at 12:34
  • I'm using the mail gem and picking up the connector out of that - so AFAIK this should not be using `examine`. I have added the relevant code above. – Cy Walker Feb 04 '13 at 22:41
  • Try to add `:read_only => false` to `Mail.defaults`. As far as I can tell, it should be the default, but somehow the folder seems to be read-only, otherwise the `STORE` command would succeed. – eugen Feb 04 '13 at 23:12
  • Thanks eugen but did not make any difference. I also just tested against a brand new account with exactly the same results – Cy Walker Feb 04 '13 at 23:42
  • Its interesting (frustrating!) that uid_copy happily adds the 'Archive' label in gmail. Is there a way (other than the above) to remove the 'Inbox' label by any chance?? – Cy Walker Feb 05 '13 at 00:18

1 Answers1

1

Fixed... I needed to explicitly select the INBOX before it would allow me to make any STORE changes. You can not rely on defaulting to the INBOX when connecting, even though it looks like you 'in' the INBOX.

connector.uid_copy(item_uid, "Archive")
connector.select("INBOX")   <== Need to explicitly select the INBOX
connector.uid_store(item_uid, "+FLAGS", [:Deleted])

Thats to tricky for a screw driver monkey like me to have to work out!! :)

Cy Walker
  • 41
  • 5
  • Normally the `Mail.all` should by default select the `INBOX` folder, but apparently that's not the case. Good job of finding a solution! – eugen Feb 05 '13 at 08:27