A Python application that generates a personalized compliment for a specific person and sends it via email. It is designed to be scheduled to run at a random time each day.
- Clone this repository.
- Install the required dependencies:
pip install -r requirements.txt
. - Create a
.env
file to store your environment variables (email details, OpenAI API key, recipient's email, and name). - Run the script manually to test it:
python main.py
.
This project requires certain environment variables to be set in a .env
file in the root directory of the project. These are:
OPENAI_API_KEY
: Your OpenAI API key. Used for generating the compliment.EMAIL_PASSWORD
: The password for the email account you're using to send the email.EMAIL_ADDRESS
: The email address you're using to send the email.SMTP_SERVER
: The SMTP server for your email provider (for example, for Gmail it'ssmtp.gmail.com
).SMTP_PORT
: The SMTP port for your email provider (for Gmail, use587
with TLS).TO_EMAIL
: The recipient's email address. This is where the compliment will be sent.NAME
: The name of the recipient. This will be used to personalize the compliment.
Please do not commit your .env
file to the repository. This file should be kept private as it contains sensitive information.
Here's an example of what your .env
file should look like:
OPENAI_API_KEY=your-openai-api-key
EMAIL_PASSWORD=your-email-password
[email protected]
SMTP_SERVER=smtp.example.com
SMTP_PORT=587
[email protected]
NAME=RecipientName
Please replace the values above with your actual information.
You can schedule the script to run daily at a random time using either the Windows Task Scheduler or a cron job in Linux.
Follow these steps to schedule the task with Task Scheduler:
- Open the Task Scheduler application.
- Click on
Create Basic Task
. - Name the task and set the trigger to
Daily
. - In the
Action
step, selectStart a program
and browse to the Python executable file (usually located in your Python installation directory) and add the path tomain.py
script in theAdd arguments
section. - Finish the setup.
You might need to adjust these steps based on your specific version of Windows.
To schedule the script to run daily with cron, follow these steps:
- Open your terminal.
- Type
crontab -e
to edit the cron file. - Add a new line in the following format:
0 7 * * * /usr/bin/python3 /path/to/your/script/main.py >> /path/to/your/logfile.log 2>&1
This will run the script daily at 7:00 AM. Adjust the time according to your needs. The output will be logged to the specified log file. - Save and close the file.
Please note that the frequency and exact timing will depend on the specific configuration of your cron file.
This project is licensed under the MIT License. See the LICENSE file for details.