send email when rdv confirmed
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from src.mail.mail_confirmation import read_mails
|
||||
from src.mail.mail_confirmation import read_mails_and_find_confirmation_contacts
|
||||
|
||||
if __name__ == '__main__':
|
||||
read_mails()
|
||||
read_mails_and_find_confirmation_contacts()
|
||||
@@ -10,6 +10,8 @@ from builtins import list
|
||||
|
||||
from src import params
|
||||
from src.db.mongo_manager import MONGO_STORE_MANAGER
|
||||
from src.notification.AcceptedResultPojo import get_accepted_result_from
|
||||
from src.notification.mailer import Mailer
|
||||
from src.pojo.mail.mail_pojo import MailPojo, MailAddress
|
||||
from src.proxy.proxy_type import ProxyType
|
||||
from src.workers.link_validator import LinkValidator
|
||||
@@ -45,16 +47,7 @@ class MailConfirmationReader():
|
||||
mail_list = []
|
||||
print("read mails from {}".format(self.login))
|
||||
# self.show_folders(imap)
|
||||
# total number of emails
|
||||
# get mails from inbox
|
||||
# (\Archive \HasNoChildren) = "Archive"
|
||||
# (\Junk \HasNoChildren) = "Bulk"
|
||||
# (\Drafts \HasNoChildren) = "Draft"
|
||||
# (\HasNoChildren) = "Inbox"
|
||||
# (\Sent \HasNoChildren) = "Sent"
|
||||
# (\Trash \HasNoChildren) = "Trash"
|
||||
mail_list.extend(self._get_messages_from_folder(imap))
|
||||
# mail_list.extend(self._get_messages_from_folder(imap, folder="Bulk"))
|
||||
# close the connection and logout
|
||||
imap.close()
|
||||
imap.logout()
|
||||
@@ -137,8 +130,8 @@ def need_to_valid_url(url: str, successful_items) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def read_mails():
|
||||
# get email address
|
||||
def read_mails_and_find_confirmation_contacts():
|
||||
mailer = Mailer()
|
||||
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
|
||||
# # mail_address1 = MailAddress(mail="appointment2022@aol.com", password="gyilpmvyyvlcaviq")
|
||||
# # mail_address2 = MailAddress(mail="chenpeijun@aol.com", password="ytifuwguknzifqyb")
|
||||
@@ -153,8 +146,13 @@ def read_mails():
|
||||
for mail in mail_list:
|
||||
mail_reader = MailConfirmationReader(mail.mail, mail.password)
|
||||
executor.submit(mail_reader.read_emails, mails_messages)
|
||||
|
||||
if len(mails_messages) > 0:
|
||||
successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
|
||||
for mail in mails_messages:
|
||||
message_body = mail.body
|
||||
for item in successful_items:
|
||||
if item.id in message_body:
|
||||
mailer.send_email(get_accepted_result_from(item), to_all=False)
|
||||
print(mail.mail_address)
|
||||
print(mail.subject)
|
||||
print(mail.body)
|
||||
@@ -162,4 +160,4 @@ def read_mails():
|
||||
|
||||
# check whether the url has already been clicked
|
||||
if __name__ == '__main__':
|
||||
read_mails()
|
||||
read_mails_and_find_confirmation_contacts()
|
||||
|
||||
@@ -188,6 +188,7 @@ def write_destinaire_email(valid_contacts: list, generate_passport=True):
|
||||
row += 1
|
||||
workbook.close()
|
||||
|
||||
|
||||
def save_mails_to_db():
|
||||
excel_reader = ExcelHelper()
|
||||
emails = excel_reader.read_email_pojo("/Users/lpan/Downloads/aol_mails_21.xlsx")
|
||||
@@ -195,14 +196,15 @@ def save_mails_to_db():
|
||||
for mail in emails:
|
||||
MONGO_STORE_MANAGER.save_destinary_emails(mail)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# excel_reader = ExcelHelper()
|
||||
# contacts = excel_reader.read_names("/Users/lpan/Documents/rdv/real_contacts_318.xlsx")
|
||||
# contacts = excel_reader.read_names("/Users/lpan/Documents/rdv/backup_500.xlsx")
|
||||
# print(contacts)
|
||||
# write_new_contacts_to_excel(valid_contacts=contacts)
|
||||
|
||||
save_mails_to_db()
|
||||
# for mail in excel_reader.read_mails_and_pwd():
|
||||
# MONGO_STORE_MANAGER.insert_email(mail)
|
||||
# for i in range(1,2):
|
||||
# for i in range(1, 64):
|
||||
# print(get_random_phone_numbers())
|
||||
Reference in New Issue
Block a user