can read sina mails
This commit is contained in:
@@ -42,13 +42,14 @@ def show_folders(imap) -> list:
|
|||||||
def create_imap(login: str):
|
def create_imap(login: str):
|
||||||
# create an IMAP4 class with SSL
|
# create an IMAP4 class with SSL
|
||||||
if DOMAIN_163 in login:
|
if DOMAIN_163 in login:
|
||||||
imap = imaplib.IMAP4_SSL(IMAP_SERVER_163)
|
imap = IMAPClient(IMAP_SERVER_163, use_uid=True)
|
||||||
elif DOMAIN_YAHOO in login:
|
elif DOMAIN_YAHOO in login:
|
||||||
imap = imaplib.IMAP4_SSL(YAHOO_IMAP_SERVER)
|
imap = imaplib.IMAP4_SSL(YAHOO_IMAP_SERVER)
|
||||||
elif DOMAIN_GMX in login:
|
elif DOMAIN_GMX in login:
|
||||||
imap = imaplib.IMAP4_SSL(SERVER_GMX)
|
imap = imaplib.IMAP4_SSL(SERVER_GMX)
|
||||||
elif DOMAIN_SINA in login:
|
elif DOMAIN_SINA in login:
|
||||||
imap = imaplib.IMAP4_SSL(IMAP_SERVER_SINA)
|
# imap = imaplib.IMAP4_SSL(IMAP_SERVER_SINA)
|
||||||
|
imap = IMAPClient(IMAP_SERVER_SINA, use_uid=True)
|
||||||
elif DOMAIN_HOTMAIL in login:
|
elif DOMAIN_HOTMAIL in login:
|
||||||
imap = imaplib.IMAP4_SSL(HOTMAIL_IMAP_SERVER)
|
imap = imaplib.IMAP4_SSL(HOTMAIL_IMAP_SERVER)
|
||||||
elif DOMAIN_RAMBLER_RU in login:
|
elif DOMAIN_RAMBLER_RU in login:
|
||||||
|
|||||||
+22
-19
@@ -25,6 +25,7 @@ EMAIL_ADDRESS_REGEX = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b'
|
|||||||
date_format = "%d-%b-%Y" # DD-Mon-YYYY e.g., 3-Mar-2014
|
date_format = "%d-%b-%Y" # DD-Mon-YYYY e.g., 3-Mar-2014
|
||||||
REDIRECTION_MAILS = "appointment2022@aol.com, chenpeijun@aol.com,hongjiang176@aol.com,ciyuexie@aol.com,rutger.62@aol.com,ciccidaniel@aol.com,armasgoodman@aol.com,wknd.gemerine@aol.com,rafmail1981@aol.com,tonovichivanenaki@aol.com,hetland.ari@aol.com,mateusiversen@aol.com,lacerdaraffaello@aol.com,anasida76@aol.com,liamolinari@aol.com,sen70zib@aol.com,mezeiderrick@aol.com,stanisl49avchic@aol.com,damcvrobaneuron@aol.com,suyzanna_fleona@aol.com,dxealing.dissa@aol.com,hogg.karen@aol.com,obocharovamarina@aol.com,buchholzjohann@aol.com,orn.cecchini@aol.com,percivaltorgersen@aol.com,candalgudrun@aol.com,filimonis.76@aol.com,bengann_100@aol.com,axelhanne@aol.com,tiffanylarochelle@aol.com,nicoleta.r@aol.com,eichenbaum.1963@aol.com,kotensasharev@aol.com,samognat32@aol.com,edem_headshot@aol.com,kozmakuzmich1960@aol.com,damonsvensson@aol.com,anders.riva@aol.com,caiminwei123@gmail.com,yulingguo086@gmail.com,yingxiaolu086@gmail.com,lijiazhen0035@gmail.com,fangp370@gmail.com,huangyayu10086@gmail.com,fuziyuan110@gmail.com,xinyingdu886@gmail.com,yasiaforever.1971@aol.com,lukaszfidalgo@aol.com,zaichi29@aol.com,prostotakitak.1974@aol.com,mo90nroe@aol.com,blonde.87@aol.com,dimidrol.1969@aol.com"
|
REDIRECTION_MAILS = "appointment2022@aol.com, chenpeijun@aol.com,hongjiang176@aol.com,ciyuexie@aol.com,rutger.62@aol.com,ciccidaniel@aol.com,armasgoodman@aol.com,wknd.gemerine@aol.com,rafmail1981@aol.com,tonovichivanenaki@aol.com,hetland.ari@aol.com,mateusiversen@aol.com,lacerdaraffaello@aol.com,anasida76@aol.com,liamolinari@aol.com,sen70zib@aol.com,mezeiderrick@aol.com,stanisl49avchic@aol.com,damcvrobaneuron@aol.com,suyzanna_fleona@aol.com,dxealing.dissa@aol.com,hogg.karen@aol.com,obocharovamarina@aol.com,buchholzjohann@aol.com,orn.cecchini@aol.com,percivaltorgersen@aol.com,candalgudrun@aol.com,filimonis.76@aol.com,bengann_100@aol.com,axelhanne@aol.com,tiffanylarochelle@aol.com,nicoleta.r@aol.com,eichenbaum.1963@aol.com,kotensasharev@aol.com,samognat32@aol.com,edem_headshot@aol.com,kozmakuzmich1960@aol.com,damonsvensson@aol.com,anders.riva@aol.com,caiminwei123@gmail.com,yulingguo086@gmail.com,yingxiaolu086@gmail.com,lijiazhen0035@gmail.com,fangp370@gmail.com,huangyayu10086@gmail.com,fuziyuan110@gmail.com,xinyingdu886@gmail.com,yasiaforever.1971@aol.com,lukaszfidalgo@aol.com,zaichi29@aol.com,prostotakitak.1974@aol.com,mo90nroe@aol.com,blonde.87@aol.com,dimidrol.1969@aol.com"
|
||||||
|
|
||||||
|
|
||||||
def check_email_address(email):
|
def check_email_address(email):
|
||||||
# pass the regular expression
|
# pass the regular expression
|
||||||
# and the string into the fullmatch() method
|
# and the string into the fullmatch() method
|
||||||
@@ -58,10 +59,18 @@ class MailReader():
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def show_folders(imap) -> list:
|
def show_folders(imap) -> list:
|
||||||
folders = []
|
folders = []
|
||||||
for i in imap.list()[1]:
|
isImapClient = isinstance(imap, IMAPClient)
|
||||||
l = i.decode().split(' "/" ')
|
if not isImapClient:
|
||||||
folders.append(l[1])
|
for i in imap.list()[1]:
|
||||||
return folders
|
l = i.decode().split(' "/" ')
|
||||||
|
folders.append(l[1])
|
||||||
|
return folders
|
||||||
|
else:
|
||||||
|
list = imap.list_folders()
|
||||||
|
for i in list:
|
||||||
|
name = i[-1]
|
||||||
|
folders.append(name)
|
||||||
|
return folders
|
||||||
|
|
||||||
def read_emails(self, mails_messages: list) -> list:
|
def read_emails(self, mails_messages: list) -> list:
|
||||||
imap = create_imap(self.login)
|
imap = create_imap(self.login)
|
||||||
@@ -86,7 +95,10 @@ class MailReader():
|
|||||||
mail_list.extend(self._get_messages_from_folder(imap, subject=VALIDATION_URL_SUBJECT_EN,
|
mail_list.extend(self._get_messages_from_folder(imap, subject=VALIDATION_URL_SUBJECT_EN,
|
||||||
folder=folder))
|
folder=folder))
|
||||||
else:
|
else:
|
||||||
mail_list.extend(self._get_messages_from_folder_for_imapclient(imap))
|
folder_list = self.show_folders(imap)
|
||||||
|
for folder in folder_list:
|
||||||
|
print("folder is " + folder)
|
||||||
|
mail_list.extend(self._get_messages_from_folder_for_imapclient(imap, folder=folder))
|
||||||
if DOMAIN_HOTMAIL in self.login:
|
if DOMAIN_HOTMAIL in self.login:
|
||||||
mail_list.extend(
|
mail_list.extend(
|
||||||
self._get_messages_from_folder_for_imapclient(imap, folder="Junk"))
|
self._get_messages_from_folder_for_imapclient(imap, folder="Junk"))
|
||||||
@@ -166,7 +178,7 @@ class MailReader():
|
|||||||
subject = email_message.get('subject')
|
subject = email_message.get('subject')
|
||||||
# print("{}, {},{}".format(from_address, subject, email_message))
|
# print("{}, {},{}".format(from_address, subject, email_message))
|
||||||
body = ""
|
body = ""
|
||||||
if "no-reply@hermes.com" in from_address:
|
if "no-reply@hermes.com" in from_address or "appointment2022@aol.com":
|
||||||
for part in email_message.walk():
|
for part in email_message.walk():
|
||||||
print(part.get_content_type())
|
print(part.get_content_type())
|
||||||
if part.get_content_type() == "text/html":
|
if part.get_content_type() == "text/html":
|
||||||
@@ -219,7 +231,9 @@ def need_to_check_email(mail: str, successful_items) -> bool:
|
|||||||
if mail == "lakrishstarko@aol.com":
|
if mail == "lakrishstarko@aol.com":
|
||||||
print("found")
|
print("found")
|
||||||
if len(filtered_items) > 0:
|
if len(filtered_items) > 0:
|
||||||
validated_items = list(filter(lambda filtered_item: filtered_item.url_validated is not None and filtered_item.url_validated is True, filtered_items))
|
validated_items = list(filter(
|
||||||
|
lambda filtered_item: filtered_item.url_validated is not None and filtered_item.url_validated is True,
|
||||||
|
filtered_items))
|
||||||
if len(validated_items) > 0:
|
if len(validated_items) > 0:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
@@ -227,24 +241,13 @@ def need_to_check_email(mail: str, successful_items) -> bool:
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# for item in filtered_items:
|
|
||||||
# if mail in item.email:
|
|
||||||
# print("url_validated for {} is {}".format(mail, item.url_validated))
|
|
||||||
# if item.url_validated is not None:
|
|
||||||
# return not item.url_validated
|
|
||||||
# else:
|
|
||||||
# # if url-validated is none, need to check email
|
|
||||||
# return True
|
|
||||||
# # if the email has not been booked, we needn't read mails.
|
|
||||||
# # return True
|
|
||||||
# return False
|
|
||||||
|
|
||||||
|
|
||||||
def read_mails():
|
def read_mails():
|
||||||
# check time before start checking emails
|
# check time before start checking emails
|
||||||
if is_time_between(time(7, 30), time(19, 30)):
|
if is_time_between(time(7, 30), time(19, 30)):
|
||||||
# get email address
|
# get email address
|
||||||
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
|
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
|
||||||
|
# mail_address1 = MailAddress(mail="vql8p2@sina.com", password="cf510636770153a8")
|
||||||
# mail_address1 = MailAddress(mail="appointment2022@aol.com", password="gyilpmvyyvlcaviq")
|
# mail_address1 = MailAddress(mail="appointment2022@aol.com", password="gyilpmvyyvlcaviq")
|
||||||
# mail_address1 = MailAddress(mail="chenpeijun@aol.com", password="ytifuwguknzifqyb")
|
# mail_address1 = MailAddress(mail="chenpeijun@aol.com", password="ytifuwguknzifqyb")
|
||||||
# # mail_address3 = MailAddress(mail="ciyuexie@aol.com", password="czezlmmyypokdfce")
|
# # mail_address3 = MailAddress(mail="ciyuexie@aol.com", password="czezlmmyypokdfce")
|
||||||
|
|||||||
Reference in New Issue
Block a user