简体   繁体   English

无法使用Rails邮件gem在GMail收件箱上设置:DELETE标志

[英]Can not set :DELETE flag on GMail Inbox using rails mail gem

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 我正在使用ruby 1.9.2,rails 3.2.10,邮件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; connector是从这里拿起的;

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

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. 即使看起来好像在INBOX内,也不能依靠默认的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!! 对于像我这样的螺丝起子猴子来说,这很麻烦! :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM