feat: implement real IMAP message parsing with native CouchDB attachments
- Replace placeholder message generation with actual IMAP message fetching using go-message library - Add per-account CouchDB databases for better organization and isolation - Implement native CouchDB attachment storage with proper revision management - Add command line argument parsing with --max-messages flag for controlling message processing limits - Support both sync and archive modes with proper document synchronization - Add comprehensive test environment with Podman containers (GreenMail IMAP server + CouchDB) - Implement full MIME multipart parsing for proper body and attachment extraction - Add TLS and plain IMAP connection support based on port configuration - Update configuration system to support sync vs archive modes - Create test scripts and sample data for development and testing Key technical improvements: - Real email envelope and header processing with go-imap v2 API - MIME Content-Type and Content-Disposition parsing for attachment detection - CouchDB document ID generation using mailbox_uid format for uniqueness - Duplicate detection and prevention to avoid re-storing existing messages - Proper error handling and connection management for IMAP operations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
79f19a8877
commit
ea6235b674
22 changed files with 1262 additions and 66 deletions
67
test/start-test-env.sh
Executable file
67
test/start-test-env.sh
Executable file
|
|
@ -0,0 +1,67 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Start test environment for manual testing
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
echo "🚀 Starting mail2couch test environment..."
|
||||
|
||||
# Start containers
|
||||
echo "Starting containers..."
|
||||
podman-compose -f podman-compose.yml up -d
|
||||
|
||||
# Wait for services
|
||||
echo "Waiting for services to be ready..."
|
||||
sleep 10
|
||||
|
||||
# Check CouchDB
|
||||
echo "Checking CouchDB..."
|
||||
timeout=30
|
||||
while ! curl -s http://localhost:5984/_up > /dev/null 2>&1; do
|
||||
timeout=$((timeout - 1))
|
||||
if [ $timeout -le 0 ]; then
|
||||
echo "❌ CouchDB failed to start"
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
echo "✅ CouchDB is ready at http://localhost:5984"
|
||||
|
||||
# Check IMAP
|
||||
echo "Checking IMAP server..."
|
||||
timeout=30
|
||||
while ! nc -z localhost 3143 > /dev/null 2>&1; do
|
||||
timeout=$((timeout - 1))
|
||||
if [ $timeout -le 0 ]; then
|
||||
echo "❌ IMAP server failed to start"
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
echo "✅ IMAP server is ready at localhost:3143"
|
||||
|
||||
# Populate test data
|
||||
echo "Populating test messages..."
|
||||
./populate-test-messages.sh
|
||||
|
||||
echo ""
|
||||
echo "🎉 Test environment is ready!"
|
||||
echo ""
|
||||
echo "Services:"
|
||||
echo " - CouchDB: http://localhost:5984 (admin/password)"
|
||||
echo " - CouchDB Web UI: http://localhost:5984/_utils"
|
||||
echo " - IMAP Server: localhost:3143"
|
||||
echo " - IMAPS Server: localhost:3993"
|
||||
echo " - SMTP Server: localhost:3025"
|
||||
echo ""
|
||||
echo "Test accounts:"
|
||||
echo " - testuser1:password123"
|
||||
echo " - testuser2:password456"
|
||||
echo " - syncuser:syncpass"
|
||||
echo " - archiveuser:archivepass"
|
||||
echo ""
|
||||
echo "To run mail2couch:"
|
||||
echo " cd ../go && ./mail2couch -config ../test/config-test.json"
|
||||
echo ""
|
||||
echo "To stop the environment:"
|
||||
echo " ./stop-test-env.sh"
|
||||
Loading…
Add table
Add a link
Reference in a new issue