Files
Gondulf/docs/decisions/0006-email-smtp-configuration.md
Phil Skentelbery bebd47955f feat(core): implement Phase 1 foundation infrastructure
Implements Phase 1 Foundation with all core services:

Core Components:
- Configuration management with GONDULF_ environment variables
- Database layer with SQLAlchemy and migration system
- In-memory code storage with TTL support
- Email service with SMTP and TLS support (STARTTLS + implicit TLS)
- DNS service with TXT record verification
- Structured logging with Python standard logging
- FastAPI application with health check endpoint

Database Schema:
- authorization_codes table for OAuth 2.0 authorization codes
- domains table for domain verification
- migrations table for tracking schema versions
- Simple sequential migration system (001_initial_schema.sql)

Configuration:
- Environment-based configuration with validation
- .env.example template with all GONDULF_ variables
- Fail-fast validation on startup
- Sensible defaults for optional settings

Testing:
- 96 comprehensive tests (77 unit, 5 integration)
- 94.16% code coverage (exceeds 80% requirement)
- All tests passing
- Test coverage includes:
  - Configuration loading and validation
  - Database migrations and health checks
  - In-memory storage with expiration
  - Email service (STARTTLS, implicit TLS, authentication)
  - DNS service (TXT records, domain verification)
  - Health check endpoint integration

Documentation:
- Implementation report with test results
- Phase 1 clarifications document
- ADRs for key decisions (config, database, email, logging)

Technical Details:
- Python 3.10+ with type hints
- SQLite with configurable database URL
- System DNS with public DNS fallback
- Port-based TLS detection (465=SSL, 587=STARTTLS)
- Lazy configuration loading for testability

Exit Criteria Met:
✓ All foundation services implemented
✓ Application starts without errors
✓ Health check endpoint operational
✓ Database migrations working
✓ Test coverage exceeds 80%
✓ All tests passing

Ready for Architect review and Phase 2 development.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 12:21:42 -07:00

40 lines
1.3 KiB
Markdown

# 0006. Email SMTP Configuration
Date: 2024-11-20
## Status
Accepted
## Context
Email service needs SMTP configuration for sending domain verification codes. We need to support common email providers while keeping configuration simple. Modern SMTP typically uses STARTTLS on port 587 or implicit TLS on port 465.
## Decision
Support both STARTTLS and implicit TLS via configuration:
Configuration:
```
GONDULF_SMTP_HOST=smtp.example.com
GONDULF_SMTP_PORT=587
GONDULF_SMTP_USERNAME=user@example.com
GONDULF_SMTP_PASSWORD=secret
GONDULF_SMTP_FROM=noreply@example.com
GONDULF_SMTP_USE_TLS=true
```
Implementation logic:
- If `GONDULF_SMTP_PORT=465`: Use implicit TLS (smtplib.SMTP_SSL)
- If `GONDULF_SMTP_PORT=587` and `GONDULF_SMTP_USE_TLS=true`: Use STARTTLS (smtplib.SMTP with starttls())
- If `GONDULF_SMTP_PORT=25` and `GONDULF_SMTP_USE_TLS=false`: Use unencrypted SMTP (testing only)
Default to port 587 with STARTTLS as the most common modern configuration.
## Consequences
### Positive
- Supports all major email providers (Gmail, SendGrid, Mailgun, etc.)
- Simple configuration with sensible defaults
- Port number determines TLS behavior (intuitive)
- Single USE_TLS flag controls STARTTLS
### Negative
- Slightly more complex than hardcoding one approach
- Must document port/TLS combinations in `.env.example`