2013-03-05 82 views
0

我無法使IMAP STORE命令與Gmail配合使用。從谷歌搜索似乎還有其他人有這個問題,有些人似乎找到了一個修復,從來沒有說過它是什麼,有的剛剛停止。我不知道如何解決它。Gmail收件箱只讀

當我連接到Gmail,我只給只讀到郵箱訪問

2013-03-05 01:22:47-0500 [IMAP4Client (TLSMemoryBIOProtocol),client] C: '0003 EXAMINE INBOX' 
2013-03-05 01:22:47-0500 [IMAP4Client (TLSMemoryBIOProtocol),client] S: '* FLAGS (\\Answered \\Flagged \\Draft \\Deleted \\Seen)' 
2013-03-05 01:22:47-0500 [IMAP4Client (TLSMemoryBIOProtocol),client] S: '* OK [PERMANENTFLAGS()] Flags permitted.' 
2013-03-05 01:22:47-0500 [IMAP4Client (TLSMemoryBIOProtocol),client] S: '* OK [UIDVALIDITY 1] UIDs valid.' 
2013-03-05 01:22:47-0500 [IMAP4Client (TLSMemoryBIOProtocol),client] S: '* 22 EXISTS' 
2013-03-05 01:22:47-0500 [IMAP4Client (TLSMemoryBIOProtocol),client] S: '* 0 RECENT' 
2013-03-05 01:22:47-0500 [IMAP4Client (TLSMemoryBIOProtocol),client] S: '* OK [UIDNEXT 110] Predicted next UID.' 
2013-03-05 01:22:47-0500 [IMAP4Client (TLSMemoryBIOProtocol),client] S: '0003 OK [READ-ONLY] INBOX selected. (Success)' 

所以,當我選擇收件箱是隻讀

我再後來試圖刪除一條消息,我得到這個錯誤

2013-03-05 01:43:04-0500 [IMAP4Client (TLSMemoryBIOProtocol),client] C: '000E STORE 2 FLAGS.SILENT (\\Deleted)' 
2013-03-05 01:43:04-0500 [IMAP4Client (TLSMemoryBIOProtocol),client] S: '000E NO STORE attempt on READ-ONLY folder (Failure)' 

扭報告這個錯誤,在只讀文件夾,因爲我只給只讀訪問預計STORE嘗試。我如何獲得讀寫訪問權限;

Traceback (most recent call last): 
Failure: twisted.mail.imap4.IMAP4Exception: STORE attempt on READ-ONLY folder (Failure) 

RFC信息 http://tools.ietf.org/html/rfc3501#section-6.3.1

If the client is permitted to modify the mailbox, the server 
    SHOULD prefix the text of the tagged OK response with the 
    "[READ-WRITE]" response code. 

    If the client is not permitted to modify the mailbox but is 
    permitted read access, the mailbox is selected as read-only, and 
    the server MUST prefix the text of the tagged OK response to 
    SELECT with the "[READ-ONLY]" response code. Read-only access 
    through SELECT differs from the EXAMINE command in that certain 
    read-only mailboxes MAY permit the change of permanent state on a 
    per-user (as opposed to global) basis. Netnews messages marked in 
    a server-based .newsrc file are an example of such per-user 
    permanent state that can be modified with read-only mailboxes. 

我知道Gmail的IMAP實現破(http://memegenerator.net/instance/35708036) 但據我可以告訴Mail.app,雷鳥等能夠刪除郵件等什麼我失去了獲得讀寫訪問....

刪除代碼

def delete_data(self, data_hash): 
    if not self.hash_database.hash_in_list(data_hash): 
     print "Data hash isn't uploaded yet" 
     raise IOError("No such data hash uploaded") 

    else: 
     # delete it to prevent anyone from trying to download it while it is being deleted 
     self.hash_database.delete_hash(data_hash) 
     d = self.imap_connection.search("SUBJECT", "\"EMS Data ID: %s\"" % data_hash, uid = False) 
     d.addCallback(self.delete_message) 
     d.addErrback(self.deletion_error, data_hash) 
     return d 

def deletion_error(self, error, data_hash): 
    print "Couldn't delete message hash %s" % data_hash 
    print "========Deletion Error========" 
    log.err(error) 
    # restore hash to database 
    self.hash_database.add_hash(data_hash) 

    raise IOError("Couldn't delete message hash") 


def delete_message(self, id): 
    if len(id) == 0: 
     raise IOError("Hash not found, however database indicates it was uploaded") 
    d = self.imap_connection.setFlags(id[-1], ["\\Deleted"]) 
    d.addCallback(lambda result: self.imap_connection.expunge()) 
    return d 
+1

既然你知道一個可行的開源程序,首先檢查他們的代碼! – 2013-03-05 07:51:17

回答

3

您需要選擇您的INBOX而不是檢查它。檢查是以只讀方式打開郵箱的命令。

+0

哇我覺得愚蠢的猜測我的大腦看到了檢查線,就像是你已經知道它是選擇是..... .....謝謝 – Zimm3r 2013-03-05 22:23:25