This project is a Python script that automatically sends birthday greetings via email to recipients listed in a CSV file. It checks the current date and matches it against the birthdays in the file, sending a personalized message if a match is found.
- Sends personalized birthday emails
- Reads recipient data from a CSV file (
birthdays.csv) - Uses SMTP with TLS for secure email delivery
- Logs connection steps for debugging
- Scheduling to run every day
- Customizing the message dynamically using an AI API (eg. ChatGPT API)
- Encrypting
birthdays.csvto ensure safety
- Python 3.x
pandaslibrary
Install the required package:
pip install pandas
-
Email Setup
- Replace the
from_emailvariable with your Outlook email address. - Enter your email password in the
passwordvariable insidesend_mail. - Make sure your Outlook account allows SMTP connections and is not blocking less secure apps.
- Replace the
-
CSV File Format
Create abirthdays.csvfile in the same directory with the following columns:name,email,date,year John Doe,[email protected],07-22,2000name: Recipient's nameemail: Recipient's email addressdate: Birthday inMM-DDformatyear: Year of birth (used to calculate age)
-
Optional: Customize the email message inside the
email_contentstring.
Run the script:
python birthday_email.py
If there are any birthdays today, the script will send out emails to the corresponding recipients. Otherwise, it will print a message indicating that no birthdays are found.
- Loads
birthdays.csvusing pandas - Checks if today's date matches any in the file
- For each match:
- Calculates the age
- Composes a personalized email
- Sends the email using
smtplibthrough Outlook's SMTP server
- Host:
smtp-mail.outlook.com - Port:
587(TLS)
Do not hardcode your password in production code. Consider using environment variables or secure credential storage.
This project is licensed under the MIT License.