{"record":{"id":"bd81e30857958e6f","repo":"odysseus-dev/odysseus","slug":"email-account-cfg-get-account-name-or-account","errorCode":null,"errorMessage":"Email account {cfg.get('account_name') or account} has no SMTP configured","messagePattern":"Email account (.+?) has no SMTP configured","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mcp_servers/email_server.py","lineNumber":1321,"sourceCode":"        return {\n            \"error\": (\n                f\"UID {uid or message_id} exists in multiple accounts: {accounts}. \"\n                \"Call read_email again with the account name/email.\"\n            )\n        }\n    return {\"error\": f\"Email not found in any configured account. Checked: {'; '.join(errors)}\"}\n\n\ndef _smtp_ready(cfg: dict) -> bool:\n    return bool(cfg.get(\"smtp_host\") and cfg.get(\"smtp_user\") and cfg.get(\"smtp_password\"))\n\n\ndef _resolve_send_config(account=None):\n    cfg = _load_config(account)\n    if _smtp_ready(cfg):\n        return account, cfg\n    if account:\n        raise ValueError(f\"Email account {cfg.get('account_name') or account} has no SMTP configured\")\n    for row in _list_accounts_raw():\n        selector = row.get(\"id\") or row.get(\"name\") or row.get(\"imap_user\")\n        trial = _load_config(selector)\n        if _smtp_ready(trial):\n            return selector, trial\n    raise ValueError(\"No SMTP-capable email account configured\")\n\n\ndef _smtp_connect(account=None, cfg=None):\n    \"\"\"Connect to SMTP server, returns logged-in connection.\"\"\"\n    cfg = cfg or _load_config(account)\n    if not _smtp_ready(cfg):\n        raise ValueError(f\"Email account {cfg.get('account_name') or account or 'default'} has no SMTP configured\")\n    port = int(cfg.get(\"smtp_port\") or 465)\n    security = str(cfg.get(\"smtp_security\") or \"\").strip().lower()\n    if security not in {\"ssl\", \"starttls\", \"none\"}:\n        security = \"starttls\" if port == 587 else \"ssl\"\n    if security == \"starttls\":","sourceCodeStart":1303,"sourceCodeEnd":1339,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/mcp_servers/email_server.py#L1303-L1339","documentation":"Raised by _resolve_send_config when the caller explicitly names an account but _smtp_ready(cfg) is false — the loaded config is missing smtp_host, smtp_user, or smtp_password. Sending requires SMTP credentials even though IMAP reading may already work.","triggerScenarios":"Calling a send/draft tool with account=<selector> where that account's row (and env/config fallbacks) lacks any SMTP field — e.g. an account configured for IMAP-only reading.","commonSituations":"Read-only mail accounts (import/scan setups) reused for sending; SMTP password stored encrypted but the smtp_host column empty; provider requires app-specific SMTP password that was never set.","solutions":["Set smtp_host, smtp_port, smtp_user, smtp_password (and smtp_security) on that account's row/config","Verify the SMTP password is stored encrypted via src.secret_storage and decrypts correctly","If you meant to send from any account, omit the account argument so the fallback scan finds an SMTP-capable one"],"exampleFix":"# before\nsend_email(account='imap-only-acct', ...)\n# after — configure SMTP on the account, or drop the explicit selector\nsend_email(..., account='main-account-with-smtp')","handlingStrategy":"type-guard","validationCode":"if not _smtp_ready(_load_config(account)):\n    raise ValueError(f'{account} cannot send; configure SMTP or drop the selector')","typeGuard":"def can_send(account: str | None) -> bool:\n    return _smtp_ready(_load_config(account))","tryCatchPattern":"try:\n    acct, cfg = _resolve_send_config(account)\nexcept ValueError as e:\n    if 'no SMTP configured' in str(e):\n        notify_admin_to_configure_smtp(e)\n    raise","preventionTips":["Validate SMTP readiness in account-setup wizards before saving","Keep IMAP-only accounts out of send call sites","Store SMTP creds via the same encrypted path as IMAP"],"tags":["email","smtp","configuration"],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}