- Rename main.py to email_forwarder.py for better readability - Update systemd service to use in ExecStart and EnvironmentFile, remove WorkingDirectory to fix expansion issues - Update install.sh and README references - Drop-in sets PROJECT_DIR for runtime expansion Changes: - File rename: main.py -> email_forwarder.py - Service: ExecStart and EnvironmentFile now use - Docs: Updated to reflect new script name
1.6 KiB
1.6 KiB
Email Forwarder
This script forwards new emails from a source IMAP account (e.g., GMX) to a destination IMAP account (e.g., MXRoute), avoiding duplicates by tracking Message-IDs.
Setup
Run the install script: ./install.sh
This will set up the virtual environment, systemd services, and provide post-install instructions.
Configuration (.env)
SOURCE_HOST: Source IMAP server (e.g., imap.gmx.com)SOURCE_PORT: Port (default 993)SOURCE_USER: Source email/usernameSOURCE_PASS: Source passwordDEST_HOST: Destination IMAP server (e.g., yourserver.mxrouting.net)DEST_PORT: Port (default 993)DEST_USER: Destination email/usernameDEST_PASS: Destination passwordFOLDERS: Folders to sync (default "INBOX,Sent"; use "all" for all folders or comma-separated list)DRY_RUN: Set totruefor testing without forwarding (default false)UPTIME_SUCCESS_URL: URL for success pingUPTIME_FAIL_URL: URL for failure ping
How It Works
- Uses time-based search (
SINCE) withlast_run.txtto find emails since last run. - Extracts Message-ID, checks against local file and destination IMAP for duplicates.
- Forwards via IMAP APPEND; updates
last_run.txton success. - Logs activity; systemd handles Uptime Kuma pings.
Monitoring with Uptime Kuma
- Success: Pings
${UPTIME_SUCCESS_URL}after forwarding. - Failure:
OnFailurepings${UPTIME_FAIL_URL}.
Troubleshooting
- Logs:
journalctl --user -u email_forwarder.service - Test:
source venv/bin/activate && python email_forwarder.py - Timezone issues: Adjust UTC offset in script if needed.