import random import smtplib import datetime as dt import pandas as pd
birthdayList = (pd.read_csv("birthdays.csv").to_dict(orient="index")).items()
now = dt.datetime.now()
winner = [person for (index, person) in birthdayList if (person["month"], person["day"]) == (now.month, now.day)]
for i in winner:
chosen_letter = f"letter_{random.randrange(1,4)}.txt"
with open(f"letter_templates/{chosen_letter}","r") as file:
letter= file.read().replace("[NAME]",i['name'])
email="xxxxxx@gmail.com"
password="xxxxxxxx"
with smtplib.SMTP("smtp.gmail.com") as connection:
connection.starttls()
connection.login(user=email, password=password)
connection.sendmail(from_addr=email, to_addrs=i['email'], msg=f"Subject: Happy Birthday!!\n\n{letter}")
When I run this code anywhere else, it works as intended and sends an email, but when I try to run it here in pythonanywhere, it doesn't work.
I placed Print(winner)
after the 'winner =... ' line. In pythonanywhere, it prints out as an empty list.
Pls help ;-