Key improvements: - Either email OR username can be empty (but not both) - Enhanced validation logic for authentication methods - Improved error messages showing available auth methods - More flexible IMAPConnection constructor with better defaults Authentication options: 1. Email-only: SOURCE_EMAIL=user@domain.de, SOURCE_USERNAME= 2. Username-only: SOURCE_EMAIL=, SOURCE_USERNAME=username123 3. Both (fallback): Provide both for automatic fallback 4. Dual method: Username tried first, email as fallback Configuration updates: - Update .env.template with all four authentication examples - Clarify requirements and optional nature of fields - Add comprehensive authentication scenarios Documentation updates: - Expand README with four authentication options - Add troubleshooting for different auth combinations - Clarify flexible requirements (either email OR username required) This makes the script compatible with even more email providers and hosting scenarios.
204 lines
7.2 KiB
Text
204 lines
7.2 KiB
Text
# ============================================================================
|
|
# EMAIL MIGRATION CONFIGURATION FILE
|
|
# ============================================================================
|
|
# Copy this file to '.env' and fill in your actual values.
|
|
# NEVER commit the .env file to version control - it contains passwords!
|
|
|
|
# ============================================================================
|
|
# SOURCE EMAIL ACCOUNT (migrating FROM) - Host Europe Example
|
|
# ============================================================================
|
|
|
|
# SOURCE_IMAP_SERVER: IMAP server hostname
|
|
# Host Europe: wpxxxxxxxx.mail.server-he.de | Gmail: imap.gmail.com | Outlook: outlook.office365.com
|
|
SOURCE_IMAP_SERVER=wp123456.mail.server-he.de
|
|
|
|
# SOURCE_IMAP_PORT: IMAP port number
|
|
# 993 (SSL recommended) | 143 (TLS/STARTTLS)
|
|
SOURCE_IMAP_PORT=993
|
|
|
|
# SOURCE_EMAIL: Your source email address
|
|
# Required if SOURCE_USERNAME is empty, optional if username is provided
|
|
# Example: user@yourdomain.de
|
|
SOURCE_EMAIL=user@example-domain.de
|
|
|
|
# SOURCE_USERNAME: Login username (alternative to email)
|
|
# Required if SOURCE_EMAIL is empty, optional if email is provided
|
|
# Some providers use separate username for login (e.g. hosteurope123, mail_user)
|
|
# Host Europe: often uses email account name or specific username
|
|
SOURCE_USERNAME=
|
|
|
|
# SOURCE_PASSWORD: Email account password
|
|
# Use your Host Europe email password (NOT app password needed here)
|
|
SOURCE_PASSWORD=your_hosteurope_password
|
|
|
|
# SOURCE_IMAP_USE_SSL: Use SSL encryption
|
|
# True (port 993) | False (port 143 with TLS)
|
|
SOURCE_IMAP_USE_SSL=True
|
|
|
|
# ============================================================================
|
|
# DESTINATION EMAIL ACCOUNT (migrating TO) - Securehost.de Example
|
|
# ============================================================================
|
|
|
|
# DEST_IMAP_SERVER: Destination IMAP server
|
|
# Securehost.de: mail.securehost.de | Common: mail.yourdomain.de | imap.provider.de
|
|
DEST_IMAP_SERVER=mail.securehost.de
|
|
|
|
# DEST_IMAP_PORT: Destination IMAP port
|
|
# 993 (SSL) | 143 (TLS/STARTTLS)
|
|
DEST_IMAP_PORT=993
|
|
|
|
# DEST_EMAIL: Your destination email address
|
|
# Required if DEST_USERNAME is empty, optional if username is provided
|
|
# Example: user@securehost.de
|
|
DEST_EMAIL=user@securehost.de
|
|
|
|
# DEST_USERNAME: Login username for destination (alternative to email)
|
|
# Required if DEST_EMAIL is empty, optional if email is provided
|
|
# Some hosting providers use separate username (e.g. user123, cpanel_user)
|
|
# Securehost.de: typically uses email or specific username
|
|
DEST_USERNAME=
|
|
|
|
# DEST_PASSWORD: Destination email password
|
|
# Your securehost.de email password
|
|
DEST_PASSWORD=your_securehost_password
|
|
|
|
# DEST_IMAP_USE_SSL: Use SSL for destination
|
|
# True (recommended) | False
|
|
DEST_IMAP_USE_SSL=True
|
|
|
|
# ============================================================================
|
|
# IMPORT FOLDER CONFIGURATION
|
|
# ============================================================================
|
|
|
|
# IMPORT_FOLDER_NAME: Where to organize imported emails
|
|
#
|
|
# Set to folder name: Creates organized subfolders
|
|
# "Imported" → Imported/INBOX, Imported/Sent, Imported/Drafts
|
|
# "Migration" → Migration/INBOX, Migration/Sent, etc.
|
|
#
|
|
# Leave empty: All emails go to main INBOX
|
|
# "" → All emails regardless of source folder → INBOX
|
|
#
|
|
# Examples: Imported | Migration_2024 | HostEurope_Backup | (empty)
|
|
IMPORT_FOLDER_NAME=Imported
|
|
|
|
# ============================================================================
|
|
# FOLDER FILTERING
|
|
# ============================================================================
|
|
|
|
# INCLUDE_FOLDERS: Only migrate these folders (comma-separated)
|
|
# Empty = migrate all folders
|
|
# Host Europe common folders: INBOX,Sent,Drafts,Trash
|
|
INCLUDE_FOLDERS=
|
|
|
|
# EXCLUDE_FOLDERS: Skip these folders (comma-separated)
|
|
# Recommended: skip trash and spam folders
|
|
EXCLUDE_FOLDERS=Trash,Spam,Junk
|
|
|
|
# ============================================================================
|
|
# MIGRATION SETTINGS
|
|
# ============================================================================
|
|
|
|
# BATCH_SIZE: Emails processed at once
|
|
# 10 (conservative) | 50 (balanced) | 100 (aggressive)
|
|
BATCH_SIZE=50
|
|
|
|
# PRESERVE_FLAGS: Keep read/unread status
|
|
# True (recommended) | False
|
|
PRESERVE_FLAGS=True
|
|
|
|
# PRESERVE_DATES: Keep original email dates
|
|
# True (recommended) | False
|
|
PRESERVE_DATES=True
|
|
|
|
# ============================================================================
|
|
# TECHNICAL SETTINGS
|
|
# ============================================================================
|
|
|
|
# IMAP_TIMEOUT: Connection timeout in seconds
|
|
# 60 (default) | 120 (slow connections) | 30 (fast connections)
|
|
IMAP_TIMEOUT=60
|
|
|
|
# LOG_LEVEL: Logging detail level
|
|
# INFO (recommended) | DEBUG (troubleshooting) | ERROR (minimal)
|
|
LOG_LEVEL=INFO
|
|
|
|
# TEMP_DOWNLOAD_DIR: Temporary files directory
|
|
# ./temp_emails (default) | /tmp/emails | C:\Temp\emails
|
|
TEMP_DOWNLOAD_DIR=./temp_emails
|
|
|
|
# ============================================================================
|
|
# AUTHENTICATION EXAMPLES
|
|
# ============================================================================
|
|
|
|
# Option 1: Email-based login (most common):
|
|
# SOURCE_EMAIL=user@domain.de
|
|
# SOURCE_USERNAME=
|
|
# → Script tries: user@domain.de
|
|
|
|
# Option 2: Username-based login:
|
|
# SOURCE_EMAIL=user@domain.de
|
|
# SOURCE_USERNAME=mail_user123
|
|
# → Script tries: mail_user123, fallback to user@domain.de
|
|
|
|
# Option 3: Username-only (email optional):
|
|
# SOURCE_EMAIL=
|
|
# SOURCE_USERNAME=mail_user123
|
|
# → Script tries: mail_user123 only
|
|
|
|
# Option 4: Email-only (username optional):
|
|
# SOURCE_EMAIL=user@domain.de
|
|
# SOURCE_USERNAME=
|
|
# → Script tries: user@domain.de only
|
|
|
|
# Host Europe specific:
|
|
# SOURCE_USERNAME=email_account_name (from Host Europe KIS)
|
|
# SOURCE_USERNAME= (if using Easy-Mail-Login)
|
|
|
|
# ============================================================================
|
|
# PROVIDER-SPECIFIC EXAMPLES
|
|
# ============================================================================
|
|
|
|
# Host Europe to Securehost.de Migration:
|
|
# SOURCE_IMAP_SERVER=wp123456.mail.server-he.de
|
|
# SOURCE_EMAIL=user@olddomain.de
|
|
# SOURCE_USERNAME=mail_account_he
|
|
# DEST_IMAP_SERVER=mail.securehost.de
|
|
# DEST_EMAIL=user@securehost.de
|
|
# DEST_USERNAME=
|
|
|
|
# Host Europe Settings:
|
|
# Server format: wpxxxxxxxx.mail.server-he.de (get from KIS)
|
|
# Port: 993 (SSL) or 143 (TLS)
|
|
# Username: Check KIS for account name or use email if Easy-Mail-Login enabled
|
|
|
|
# Securehost.de Settings:
|
|
# Server: mail.securehost.de (typical format)
|
|
# Port: 993 (SSL recommended)
|
|
# Authentication: Usually email-based, check with provider
|
|
|
|
# Other German Providers:
|
|
# Strato: imap.strato.de:993 (email login)
|
|
# 1und1/IONOS: imap.1und1.de:993 (username: username@domain)
|
|
# All-Inkl: mail.all-inkl.com:993 (username varies)
|
|
# Hetzner: mail.your-server.de:993 (email login)
|
|
|
|
# Gmail (if needed):
|
|
# imap.gmail.com:993 (requires app password, email login)
|
|
|
|
# ============================================================================
|
|
# MIGRATION EXAMPLES
|
|
# ============================================================================
|
|
|
|
# Example 1: Host Europe to Securehost.de with organization
|
|
# IMPORT_FOLDER_NAME=HostEurope_Migration
|
|
# Result: Clean separation in destination
|
|
|
|
# Example 2: Consolidate everything to main inbox
|
|
# IMPORT_FOLDER_NAME=
|
|
# Result: All emails in main INBOX
|
|
|
|
# Example 3: Test migration with one folder
|
|
# INCLUDE_FOLDERS=INBOX
|
|
# BATCH_SIZE=10
|
|
# LOG_LEVEL=DEBUG
|