An automated Secret Santa in Python β Assign participants and automatically forward wishlists!
- Automatically assigns Secret Santa pairs (with exclusion rules)
- Sends customized HTML emails to each participant
- Periodically checks the Secret Santa mailbox and forwards participants' wishlists
- Available in English and French
Warning
This is a capture from Mail (app) on macOS, the rendering may vary depending on the email client.
Indeed, email HTML/CSS has limited support across clients and some elements may not render exactly the same.
git clone https://github.com/h-escoffier/automated-secret-santa.git
cd automated-secret-santauv venv
source .venv/bin/activate # On Windows use `.venv\Scripts\activateuv pip install -r requirements.txtchmod +x secret_santa.pyAutomated Secret Santa requires some configuration before use. Please find below the steps to set it up.
Add your email configuration in the data/mail_config.json file :
{
"from_email": "example_email@gmail.com",
"password": "xxxxxxxxxxxxxxxx"
}Tip
Using Gmail, you must enable App Passwords and use the generated 16-character token following this tutorial.
Edit the participants.csv file to add your participants and their email addresses:
Alice,alice@example.com
Bob,bob@example.com
Charlie,charlie@example.com
If you want to exclude certain participants from being matched with each other, you can edit the exclusion_rules.csv file with the following format:
Alice,Bob
Charlie,Alice
Each line corresponds to a group of participants who should be excluded from each other's matches.
./secret_santa.py send-emails --budget 20β¬ --language en--budget: Set the maximum gift budget.--language: Set the language for the emails
Warning
Only the text of the email message is forwarded to the Secret Santa. Replies are removed.
Images, emojis, and attachments are not forwarded and can cause issues.
./secret_santa.py forward-emails --language en--language: Set the language for the emails
nohup ./secret_santa.py auto-forward --language en &--language: Set the language for the emails
Check if it's running:
ps aux | grep "secret_santa.py"Stop it:
kill <PID>