DinoPLayZ commited on
Commit
e2d6fda
·
verified ·
1 Parent(s): 0a7cadd

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +6 -2
main.py CHANGED
@@ -104,9 +104,11 @@ def send_email_message(subject: str, body: str, is_html=False):
104
  "content-type": "application/json"
105
  }
106
 
 
 
107
  payload = {
108
  "sender": {"name": "BIP Auto Notifier", "email": EMAIL_ADDRESS},
109
- "to": [{"email": EMAIL_RECIPIENT}],
110
  "subject": subject
111
  }
112
 
@@ -148,11 +150,13 @@ def send_email_message(subject: str, body: str, is_html=False):
148
  else:
149
  msg.attach(MIMEText(body, 'plain'))
150
 
 
 
151
  server = smtplib.SMTP('smtp.gmail.com', 587)
152
  server.starttls()
153
  server.login(EMAIL_ADDRESS, EMAIL_PASSWORD)
154
  text = msg.as_string()
155
- server.sendmail(EMAIL_ADDRESS, EMAIL_RECIPIENT, text)
156
  server.quit()
157
  logger.info(f"SMTP Email sent successfully.")
158
  return True
 
104
  "content-type": "application/json"
105
  }
106
 
107
+ recipient_list = [{"email": e.strip()} for e in EMAIL_RECIPIENT.split(",") if e.strip()]
108
+
109
  payload = {
110
  "sender": {"name": "BIP Auto Notifier", "email": EMAIL_ADDRESS},
111
+ "to": recipient_list,
112
  "subject": subject
113
  }
114
 
 
150
  else:
151
  msg.attach(MIMEText(body, 'plain'))
152
 
153
+ recipient_list = [e.strip() for e in EMAIL_RECIPIENT.split(",") if e.strip()]
154
+
155
  server = smtplib.SMTP('smtp.gmail.com', 587)
156
  server.starttls()
157
  server.login(EMAIL_ADDRESS, EMAIL_PASSWORD)
158
  text = msg.as_string()
159
+ server.sendmail(EMAIL_ADDRESS, recipient_list, text)
160
  server.quit()
161
  logger.info(f"SMTP Email sent successfully.")
162
  return True