from abc import abstractmethod from modules.configuration import Configuration import smtplib class MailingMethod: """...""" def __init__(self, company:str) -> None: config = Configuration("config.yaml") self.smtp_addr = config.config[company]["address"] self.smtp_pass = config.config[company]["password"] self.smtp_serv = config.config[company]["smtpserver"] self.watsapp_number = config.config[company]["wa_number"] self.watsapp_token = config.config[company]["wa_token"] @abstractmethod def send(self): ... class SMTPMAiling(MailingMethod): """...""" def server_auth(self): self.server = smtplib.SMTP(self.smtp_serv, 465) self.server.starttls() self.server.login(self.smtp_addr, self.smtp_pass) def server_quit(self): self.server.quit() def send(self, to_email: str, subject: str, message: str): self.server.sendmail(self.smtp_addr, to_email, f"Subject: {subject}\n\n{message}") return "SMTP" class WhatsAppMailing(MailingMethod): def send(self): return "WhatsApp"