reset POP3 flags
call RSET POP3 command to reset "seen" flag if supported by the POP3 server darcs-hash:20060726194755-86b55-3e17c219f71aa5ca4db65f6ad8131c0222dd85b0.gz
This commit is contained in:
@@ -452,6 +452,10 @@ class POP3Connection(MailConnection):
|
|||||||
def get_mail(self, index):
|
def get_mail(self, index):
|
||||||
POP3Connection._logger.debug("Getting mail " + str(index))
|
POP3Connection._logger.debug("Getting mail " + str(index))
|
||||||
ret, data, size = self.connection.retr(index)
|
ret, data, size = self.connection.retr(index)
|
||||||
|
try:
|
||||||
|
self.connection.rset()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
if ret[0:3] == '+OK':
|
if ret[0:3] == '+OK':
|
||||||
return self.format_message(email.message_from_string('\n'.join(data)))
|
return self.format_message(email.message_from_string('\n'.join(data)))
|
||||||
return u"Error while fetching mail " + str(index)
|
return u"Error while fetching mail " + str(index)
|
||||||
@@ -459,6 +463,10 @@ class POP3Connection(MailConnection):
|
|||||||
def get_mail_summary(self, index):
|
def get_mail_summary(self, index):
|
||||||
POP3Connection._logger.debug("Getting mail summary " + str(index))
|
POP3Connection._logger.debug("Getting mail summary " + str(index))
|
||||||
ret, data, size = self.connection.retr(index)
|
ret, data, size = self.connection.retr(index)
|
||||||
|
try:
|
||||||
|
self.connection.rset()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
if ret[0:3] == '+OK':
|
if ret[0:3] == '+OK':
|
||||||
return self.format_message_summary(email.message_from_string('\n'.join(data)))
|
return self.format_message_summary(email.message_from_string('\n'.join(data)))
|
||||||
return u"Error while fetching mail " + str(index)
|
return u"Error while fetching mail " + str(index)
|
||||||
|
|||||||
@@ -164,8 +164,10 @@ class POP3Connection_TestCase(unittest.TestCase):
|
|||||||
make_test(["+OK 10 octets\r\n" + \
|
make_test(["+OK 10 octets\r\n" + \
|
||||||
"From: user@test.com\r\n" + \
|
"From: user@test.com\r\n" + \
|
||||||
"Subject: subject test\r\n\r\n" + \
|
"Subject: subject test\r\n\r\n" + \
|
||||||
"mymessage\r\n.\r\n"], \
|
"mymessage\r\n.\r\n",
|
||||||
["RETR 1\r\n"], \
|
"+OK\r\n"], \
|
||||||
|
["RETR 1\r\n",
|
||||||
|
"RSET\r\n"], \
|
||||||
lambda self: \
|
lambda self: \
|
||||||
self.assertEquals(self.pop3connection.get_mail_summary(1), \
|
self.assertEquals(self.pop3connection.get_mail_summary(1), \
|
||||||
(u"From : user@test.com\n" + \
|
(u"From : user@test.com\n" + \
|
||||||
@@ -176,8 +178,39 @@ class POP3Connection_TestCase(unittest.TestCase):
|
|||||||
make_test(["+OK 10 octets\r\n" + \
|
make_test(["+OK 10 octets\r\n" + \
|
||||||
"From: user@test.com\r\n" + \
|
"From: user@test.com\r\n" + \
|
||||||
"Subject: subject test\r\n\r\n" + \
|
"Subject: subject test\r\n\r\n" + \
|
||||||
"mymessage\r\n.\r\n"], \
|
"mymessage\r\n.\r\n",
|
||||||
["RETR 1\r\n"], \
|
"+OK\r\n"], \
|
||||||
|
["RETR 1\r\n",
|
||||||
|
"RSET\r\n"], \
|
||||||
|
lambda self: \
|
||||||
|
self.assertEquals(self.pop3connection.get_mail(1), \
|
||||||
|
(u"From : user@test.com\n" + \
|
||||||
|
u"Subject : subject test\n\n" + \
|
||||||
|
u"mymessage\n", \
|
||||||
|
u"user@test.com")))
|
||||||
|
|
||||||
|
test_unsupported_reset_command_get_mail_summary = \
|
||||||
|
make_test(["+OK 10 octets\r\n" + \
|
||||||
|
"From: user@test.com\r\n" + \
|
||||||
|
"Subject: subject test\r\n\r\n" + \
|
||||||
|
"mymessage\r\n.\r\n",
|
||||||
|
"-ERR unknown command\r\n"], \
|
||||||
|
["RETR 1\r\n",
|
||||||
|
"RSET\r\n"], \
|
||||||
|
lambda self: \
|
||||||
|
self.assertEquals(self.pop3connection.get_mail_summary(1), \
|
||||||
|
(u"From : user@test.com\n" + \
|
||||||
|
u"Subject : subject test\n\n", \
|
||||||
|
u"user@test.com")))
|
||||||
|
|
||||||
|
test_unsupported_reset_command_get_mail = \
|
||||||
|
make_test(["+OK 10 octets\r\n" + \
|
||||||
|
"From: user@test.com\r\n" + \
|
||||||
|
"Subject: subject test\r\n\r\n" + \
|
||||||
|
"mymessage\r\n.\r\n",
|
||||||
|
"-ERR unknown command\r\n"], \
|
||||||
|
["RETR 1\r\n",
|
||||||
|
"RSET\r\n"], \
|
||||||
lambda self: \
|
lambda self: \
|
||||||
self.assertEquals(self.pop3connection.get_mail(1), \
|
self.assertEquals(self.pop3connection.get_mail(1), \
|
||||||
(u"From : user@test.com\n" + \
|
(u"From : user@test.com\n" + \
|
||||||
|
|||||||
Reference in New Issue
Block a user