mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-06-26 18:03:05 +08:00
refactor: modularize IMAP server with fixes and E2E tests - Modularize IMAP server into imap_server, imap_mailbox, imap_message, imap_http_client, parse_email, config, models - Support dual login: JWT token and address+password via backend - Add STARTTLS support with configurable TLS cert/key - Fix FETCH/STORE returning UID instead of sequence number (RFC 3501) - Implement IMessageFile.open() for correct BODY[] raw MIME delivery - Add UIDNEXT to SELECT response via _cbSelectWork override - Use per-restart UIDVALIDITY to force client resync - Pass raw MIME to SimpleMessage for accurate RFC822.SIZE - Fix SENT mailbox returning empty source - Handle CREATE command gracefully for Thunderbird compatibility - Add IMAP E2E tests: auth, LIST, SELECT, STATUS, FETCH, SEARCH, STORE, UID FETCH, BODY[] integrity, size, seq numbers, SENT mailbox - Add SMTP E2E tests using nodemailer: send plain/HTML, auth failure, sendbox verification - Add sendTestMail helper using admin/send_mail Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
41 lines
1015 B
Python
41 lines
1015 B
Python
import logging
|
|
from pydantic import field_validator
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
logging.basicConfig(
|
|
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
|
)
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
_logger.setLevel(logging.INFO)
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
proxy_url: str = "http://localhost:8787"
|
|
port: int = 8025
|
|
imap_port: int = 11143
|
|
basic_password: str = ""
|
|
imap_tls_cert: str = ""
|
|
imap_tls_key: str = ""
|
|
imap_cache_size: int = 500
|
|
imap_http_timeout: float = 30.0
|
|
|
|
model_config = SettingsConfigDict(env_file=".env")
|
|
|
|
@field_validator("imap_cache_size")
|
|
@classmethod
|
|
def cache_size_positive(cls, v):
|
|
if v <= 0:
|
|
raise ValueError("imap_cache_size must be > 0")
|
|
return v
|
|
|
|
@field_validator("imap_http_timeout")
|
|
@classmethod
|
|
def timeout_positive(cls, v):
|
|
if v <= 0:
|
|
raise ValueError("imap_http_timeout must be > 0")
|
|
return v
|
|
|
|
|
|
settings = Settings()
|