Reputation: 247
I have created the app and it works perfectly and sends an alert. However, at this time it is only able to send one user an email. How can I add more users as recipients apart from [email protected]?
import pandas as pd
import smtplib
from email.message import EmailMessage
df = pd.read_fwf(r'factadwords.Rout', header=None)
end_str = '#--- END ---------------------------------------------------------------------------------------------------'
cols_to_check = ["0"]
def email_alert(subject,body,to):
msg = EmailMessage()
msg.set_content(body)
msg['subject'] = subject
msg['to'] = to
user = "[email protected]"
msg['from'] = user
password = "xxxxx"
server = smtplib.SMTP("smtp.gmail.com", 587)
server.starttls()
server.login(user,password)
server.send_message(msg)
server.quit()
if __name__ == '__main__':
for col in cols_to_check:
if not df[0].str.contains(end_str).any():
body = "There is no one in factadwords " + col + "."
print(body)
email_alert("Rout",body,"[email protected]")
Upvotes: 0
Views: 190
Reputation: 261
All you need to do is add more users to your recipient string
email_alert("Rout",body,"[email protected], [email protected], [email protected]")
Upvotes: 1