File tree

8 files changed

+54
-0
lines changed

8 files changed

+54
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This program will check the birthday.csv file to check if today is birthday of anyone. In case there is someone's birthday it will mail them a birthday wish based on random selection from one of three predefined templates.
2+
3+
In place of my_email enter your email id and in place of password enter the app password
4+
5+
In case using mail service other than gmail replace smtp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name,email,year,month,day
2+
fictional1,[email protected],2003,05,03
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Dear [NAME],
2+
3+
It's your birthday have a great day!
4+
5+
All my love,
6+
7+
Harsh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Dear [NAME],
2+
3+
Happy Birthday!
4+
5+
All the best for the year!
6+
7+
Harsh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Hey [NAME]
2+
3+
Happy birthday have a wonderful time today and eat lots of cake!
4+
5+
Lots of love
6+
7+
Harsh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import smtplib
2+
from datetime import datetime as dt
3+
import random
4+
import pandas as pd
5+
my_mail="your email"
6+
password="your application password"
7+
8+
file=pd.read_csv("./birthday.csv")
9+
data=pd.DataFrame(file).set_index("name")
10+
date=dt.now()
11+
today=f"{date.month}-{date.day}"
12+
for index,row in data.iterrows():
13+
birth_day=(f"{row.month}-{row.day}")
14+
if(today==today):
15+
with open(f"./letter_{random.randint(1,3)}.txt",mode="r") as wish_file:
16+
contents=wish_file.read()
17+
output=contents.replace('[NAME]',row.name)
18+
with smtplib.SMTP("smtp.gmail.com",port=587) as connection:
19+
connection.starttls()
20+
connection.login(user=my_mail,password=password)
21+
connection.sendmail(from_addr=my_mail,to_addrs=row.email,msg=f"Subject:Happy Birthday\n\n{output}")
22+
connection.close()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
smtplib
2+
datetime
3+
random
4+
pandas

0 commit comments

Comments
 (0)