diff --git a/mftp/env.example.py b/mftp/env.example.py index 75f92a3..c7ccf2f 100644 --- a/mftp/env.example.py +++ b/mftp/env.example.py @@ -47,7 +47,10 @@ # EMAIL ## Senders' Credentials (via SMTP) FROM_EMAIL = "abc@gmail.com" # Notification Sender Email-id -FROM_EMAIL_PASS = "**********" # App password for the above email-id +# SMTP Credentials +SMTP_HOST = "smtp.gmail.com" +FROM_EMAIL_USER = "xxxxxxxxxxxxxxxxxxxx" # Same as FROM_EMAIL in case of Gmail SMTP +FROM_EMAIL_PASS = "xxxxxxxxxxxxxxxxxxxx" # App password in case of Gmail SMTP ## EMAIL - Receiver's Address BCC_EMAIL_S = ["xyz@googlegroups.com", "abc@googlegroups.com"] # Multiple mails for bcc # BCC_EMAIL_S = ["xyz@googlegroups.com"] # This is how you can set single mail in a list diff --git a/mftp/mail.py b/mftp/mail.py index f0ec41f..8ba84c5 100644 --- a/mftp/mail.py +++ b/mftp/mail.py @@ -5,7 +5,7 @@ from email.mime.text import MIMEText from email.mime.base import MIMEBase from email.mime.multipart import MIMEMultipart -from env import FROM_EMAIL, FROM_EMAIL_PASS, BCC_EMAIL_S, HOSTER_EMAIL, HOSTER_INTERESTED_ROLLS, HOSTER_NAME, ROLL_MAIL, ROLL_NAME +from env import FROM_EMAIL, SMTP_HOST, FROM_EMAIL_USER, FROM_EMAIL_PASS, BCC_EMAIL_S, HOSTER_EMAIL, HOSTER_INTERESTED_ROLLS, HOSTER_NAME, ROLL_MAIL, ROLL_NAME def send_shortlists(mails, gmail_api, smtp): @@ -37,11 +37,11 @@ def send_shortlists(mails, gmail_api, smtp): import smtplib context = ssl.create_default_context() - logging.info(" [Connecting to smtp.google.com] ...") - with smtplib.SMTP_SSL("smtp.gmail.com", 465, context=context) as server: + logging.info(f" [Connecting to {SMTP_HOST}] ...") + with smtplib.SMTP_SSL(SMTP_HOST, 465, context=context) as server: logging.info(" [Connected!]") try: - server.login(FROM_EMAIL, FROM_EMAIL_PASS) + server.login(FROM_EMAIL_USER, FROM_EMAIL_PASS) logging.info(" [Logged In!]") except Exception as e: logging.error(f" Failed to log in ~ {str(e)}") @@ -172,11 +172,11 @@ def send_companies(mail, gmail_api, smtp): import smtplib context = ssl.create_default_context() - logging.info(" [Connecting to smtp.google.com] ...") - with smtplib.SMTP_SSL("smtp.gmail.com", 465, context=context) as server: + logging.info(f" [Connecting to {SMTP_HOST}] ...") + with smtplib.SMTP_SSL(SMTP_HOST, 465, context=context) as server: logging.info(" [Connected!]") try: - server.login(FROM_EMAIL, FROM_EMAIL_PASS) + server.login(FROM_EMAIL_USER, FROM_EMAIL_PASS) logging.info(" [Logged In!]") except Exception as e: logging.error(f" Failed to log in ~ {str(e)}") @@ -286,11 +286,11 @@ def send_notices(mails, smtp, gmail_api, notice_db): import smtplib context = ssl.create_default_context() - logging.info(" [Connecting to smtp.google.com] ...") - with smtplib.SMTP_SSL("smtp.gmail.com", 465, context=context) as server: + logging.info(f" [Connecting to {SMTP_HOST}] ...") + with smtplib.SMTP_SSL(SMTP_HOST, 465, context=context) as server: logging.info(" [Connected!]") try: - server.login(FROM_EMAIL, FROM_EMAIL_PASS) + server.login(FROM_EMAIL_USER, FROM_EMAIL_PASS) logging.info(" [Logged In!]") except Exception as e: logging.error(f" Failed to log in ~ {str(e)}")