-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
27 lines (23 loc) · 1.23 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import random
import smtplib
import pandas as pd
import datetime as dt
SENDER = "Bunny" # Enter Sender's (Your) Name
my_email = "[email protected]" # Enter Your Email ID
password = "password" # Enter Your Mail Password
data = pd.read_csv("birthdays.csv")
birthday_dict = data.to_dict(orient="records")
today = (dt.datetime.now().month, dt.datetime.now().day)
for index in range(0, len(birthday_dict)):
if (birthday_dict[index]["month"], birthday_dict[index]["day"]) == today:
filepath = f"letter_templates/letter_{random.randint(1, 10)}.txt"
with open(filepath) as letter:
content = letter.read()
content = content.replace("[NAME]", birthday_dict[index]["name"])
content = content.replace("[SENDER]", SENDER)
with smtplib.SMTP("smtp.gmail.com", 587) as connection:
connection.starttls()
connection.login(user=my_email, password=password)
connection.sendmail(from_addr=my_email,
to_addrs=birthday_dict[index]["email"],
msg=f'Subject:Happy Birthday {birthday_dict[index]["name"]}!\n\n{content}')