A lightweight Python script that monitors my email inbox (via IMAP) for Squarespace order notifications and prints a receipt on a thermal printer. Designed to run on a Raspberry Pi.
- Connects to your email inbox via IMAP every 2 minutes
- Checks for unread emails matching Squarespace order notifications
- Parses the order number, customer info, and details
- Prints a formatted receipt on a thermal printer via CUPS
- Marks the email as read to avoid reprinting
- Raspberry Pi (any model with network access)
- ESC/POS thermal receipt printer (I use it with an Epson TM-T20II)
- Printer connected via USB and configured in CUPS
git clone https://github.com/Neubauer-Ralf/order-printer.git
cd -order-printercp .env.example .env
nano .envFill in your credentials and printer name. See Configuration below.
python3 order_printer.pySend yourself a test email with " " in the subject to verify it picks it up and prints.
# Copy and edit the service file (update User and paths if needed)
sudo cp -orders.service /etc/systemd/system/
sudo nano /etc/systemd/system/ -orders.service
# Enable and start
sudo systemctl enable -orders
sudo systemctl start -orders
# Verify it's running
sudo systemctl status -ordersAll configuration is done via environment variables. Copy .env.example to .env and fill in your values.
| Variable | Description | Default |
|---|---|---|
ICLOUD_EMAIL |
Your iCloud email address (must be @icloud.com, not a custom domain) |
— |
ICLOUD_APP_PASSWORD |
App-specific password (generate here) | — |
IMAP_SERVER |
IMAP server address | imap.mail.me.com |
IMAP_PORT |
IMAP port | 993 |
PRINTER_NAME |
CUPS printer name (find with lpstat -p) |
— |
PRINT_WIDTH |
Thermal printer character width | 32 |
CHECK_INTERVAL |
Seconds between inbox checks | 120 |
SENDER_FILTER |
Filter emails by sender (matched against From header) | squarespace |
SUBJECT_FILTER |
Filter emails by subject (matched against Subject header) | |
LOG_FILE |
Path to log file | ~/ -orders.log |
If you use a custom email domain with iCloud+ (e.g. you@yourdomain.com), you still need to use your underlying @icloud.com address as the IMAP username. Your custom domain emails will be in the same inbox.
Apple requires an app-specific password for third-party IMAP access:
- Go to account.apple.com
- Sign-In and Security → App-Specific Passwords
- Generate a new password and copy it to your
.envfile
# Check service status
sudo systemctl status -orders
# View live logs
journalctl -u -orders -f
# Restart after config changes
sudo systemctl restart -orders
# Stop the service
sudo systemctl stop -orders- Receipt format: Edit the
format_order_receipt()function inorder_printer.py - Email parsing: Adjust regex patterns in
parse_order_info()to match your email format - Cut command: If the partial cut doesn't work, change
b'\x1d\x56\x01'tob'\x1d\x56\x00'for a full cut - Print width: Adjust
PRINT_WIDTHfor your paper size (32 for 58mm, 48 for 80mm)
================================
~ INSERT COMPANY ~
NEW ORDER!
================================
Order #: 00042
Time: 14:30 - 01.03.2026
Customer: Max Mustermann
Total: 24,90
--------------------------------
ORDER DETAILS:
--------------------------------
...
================================
Time to pack some coffee!
================================
- Python 3.7+
- No external pip packages needed (uses only stdlib)
- CUPS configured with your thermal printer
MIT