From 4d2546582be05ad0fc2cc06ab747ce96743fdbe9 Mon Sep 17 00:00:00 2001 From: Christian Moenneckes Date: Mon, 3 Feb 2025 07:24:49 +0100 Subject: [PATCH 1/3] fix some typos --- src/MailClientLibrary/mailclient/protocols/pop3.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/MailClientLibrary/mailclient/protocols/pop3.py b/src/MailClientLibrary/mailclient/protocols/pop3.py index 45a09a7..f6021ac 100644 --- a/src/MailClientLibrary/mailclient/protocols/pop3.py +++ b/src/MailClientLibrary/mailclient/protocols/pop3.py @@ -25,7 +25,7 @@ def __init__(self, useSsl:bool): MailClientError.raise_mail_client_error(MailClientError.FalseHost.format("Pop3",Variables.pop3_mail_server)) except: try: - self.pop3obj = poplib.POP3(Variables.imap_mail_server, Variables.imap_ssl_port) + self.pop3obj = poplib.POP3(Variables.pop3_mail_server, Variables.pop3_ssl_port) self.pop3obj.stls() except(poplib.error_proto): MailClientError.raise_mail_client_error(MailClientError.FalseHostOrPort.format("Pop3", Variables.pop3_mail_server, Variables.pop3_ssl_port)) @@ -82,7 +82,7 @@ def is_inbox_empty(self): def open_mail_by_criteria(self, criteria:str, value:str, firstOnly=True): """ - This function finds the first mail in the initialized imap mailbox with the given subject + This function finds the first mail in the initialized pop3 mailbox with the given subject Criteria= "From" or "Subject" (Case Sensitive) Returns the entire mail's mime as string. """ @@ -103,7 +103,7 @@ def open_mail_by_criteria(self, criteria:str, value:str, firstOnly=True): def open_mail_by_index(self,index:int): """ - This function returns the index-th mail raw context from initialized imap mailbox + This function returns the index-th mail raw context from initialized pop3 mailbox Returns False if there is no mail with the given index in mailbox """ if self.is_inbox_empty(): @@ -116,7 +116,7 @@ def open_mail_by_index(self,index:int): def delete_every_mail(self): """ - This function deletes every mail in initialized imap mailbox + This function deletes every mail in initialized pop3 mailbox Returns True if any mail is deleted otherwise False """ if self.is_inbox_empty(): @@ -131,7 +131,7 @@ def delete_every_mail(self): def delete_mail_by_criteria(self, criteria, subject, firstOnly=True): """ - This function reads an email inbox using imap protocol and deletes the email with corresponding subject. + This function reads an email inbox using pop3 protocol and deletes the email with corresponding subject. Returns True if any mail is deleted otherwise False """ deletedAny = False @@ -145,7 +145,7 @@ def delete_mail_by_criteria(self, criteria, subject, firstOnly=True): def delete_mail_by_index(self, index:int): """ - This function reads an email inbox using imap protocol and deletes the email with corresponding subject. + This function reads an email inbox using pop3 protocol and deletes the email with corresponding subject. """ if self.is_inbox_empty(): return False @@ -155,7 +155,7 @@ def delete_mail_by_index(self, index:int): return False def _get_mail_indexes_by_criteria(self, criteria, value): - """ This function iterates only through subjects of the mails in initialized imap mailbox + """ This function iterates only through subjects of the mails in initialized pop3 mailbox and returns the first index found with the given subject or sender Args: Creteria = "Subject" or "From" (CaseSensible) From 9aa8456c92f11db1b329325d244fdaacefa5c011 Mon Sep 17 00:00:00 2001 From: Christian Moenneckes Date: Mon, 3 Feb 2025 07:29:23 +0100 Subject: [PATCH 2/3] bugfix: index can have mor than one digit --- src/MailClientLibrary/mailclient/protocols/pop3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MailClientLibrary/mailclient/protocols/pop3.py b/src/MailClientLibrary/mailclient/protocols/pop3.py index f6021ac..259866c 100644 --- a/src/MailClientLibrary/mailclient/protocols/pop3.py +++ b/src/MailClientLibrary/mailclient/protocols/pop3.py @@ -47,7 +47,7 @@ def __init__(self, useSsl:bool): MailClientError.raise_mail_client_error(MailClientError.FalseCridentials.format("Pop3",Variables.pop3_username,Variables.pop3_password)) self.data = [] for mail in self.mails: - self.data.append(int(mail[:1].decode())) + self.data.append(int(mail.decode().split()[0])) def __del__(self): """ From 2875611ea3a562859fbc594baea696dee20252ff Mon Sep 17 00:00:00 2001 From: Christian Moenneckes Date: Mon, 3 Feb 2025 07:30:18 +0100 Subject: [PATCH 3/3] bugfix: force convert index to int --- src/MailClientLibrary/mailclient/protocols/pop3.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MailClientLibrary/mailclient/protocols/pop3.py b/src/MailClientLibrary/mailclient/protocols/pop3.py index 259866c..62b72c4 100644 --- a/src/MailClientLibrary/mailclient/protocols/pop3.py +++ b/src/MailClientLibrary/mailclient/protocols/pop3.py @@ -108,6 +108,7 @@ def open_mail_by_index(self,index:int): """ if self.is_inbox_empty(): return False + index = int(index) if index in self.data: byte_lines = self.pop3obj.retr(index)[1] messageText = str(message_from_bytes(b'\r\n'.join(byte_lines)))