Make SMTP config optional, falls back to IMAP host/credentials
This commit is contained in:
+16
-6
@@ -2,20 +2,30 @@
|
|||||||
# Copy this file to config.yml and fill in your credentials
|
# Copy this file to config.yml and fill in your credentials
|
||||||
|
|
||||||
webhook_url: "https://poke.com/api/v1/inbound-sms/webhook"
|
webhook_url: "https://poke.com/api/v1/inbound-sms/webhook"
|
||||||
poke_api_key: "your-api-key-here" # from https://poke.com/settings/advanced
|
poke_api_key: "your-api-key-here"
|
||||||
|
|
||||||
# MCP_API_KEY is set via environment variable (not in this file)
|
# MCP_API_KEY is set via environment variable (not in this file)
|
||||||
# It secures the MCP server so only you can use it
|
# It secures the MCP server so only you can use it
|
||||||
|
|
||||||
accounts:
|
accounts:
|
||||||
- id: default
|
# Minimal — SMTP falls back to IMAP host/credentials
|
||||||
|
- id: personal
|
||||||
imap_host: imap.gmail.com
|
imap_host: imap.gmail.com
|
||||||
imap_port: 993
|
imap_port: 993
|
||||||
imap_username: "you@gmail.com"
|
imap_username: "you@gmail.com"
|
||||||
imap_password: "your-app-password"
|
imap_password: "your-app-password"
|
||||||
smtp_host: smtp.gmail.com
|
|
||||||
smtp_port: 587
|
|
||||||
smtp_username: "you@gmail.com"
|
|
||||||
smtp_password: "your-app-password"
|
|
||||||
watch_folders:
|
watch_folders:
|
||||||
- INBOX
|
- INBOX
|
||||||
|
|
||||||
|
# Full — separate SMTP settings (only if different from IMAP)
|
||||||
|
# - id: work
|
||||||
|
# imap_host: imap.example.com
|
||||||
|
# imap_port: 993
|
||||||
|
# imap_username: "you@example.com"
|
||||||
|
# imap_password: "imap-password"
|
||||||
|
# smtp_host: smtp.example.com
|
||||||
|
# smtp_port: 587
|
||||||
|
# smtp_username: "you@example.com"
|
||||||
|
# smtp_password: "smtp-password"
|
||||||
|
# watch_folders:
|
||||||
|
# - INBOX
|
||||||
|
|||||||
+13
-12
@@ -73,27 +73,28 @@ def parse_accounts(config: dict) -> list[dict]:
|
|||||||
"imap_port": int(os.environ.get("IMAP_PORT", "993")),
|
"imap_port": int(os.environ.get("IMAP_PORT", "993")),
|
||||||
"imap_username": os.environ["IMAP_USERNAME"],
|
"imap_username": os.environ["IMAP_USERNAME"],
|
||||||
"imap_password": os.environ["IMAP_PASSWORD"],
|
"imap_password": os.environ["IMAP_PASSWORD"],
|
||||||
"smtp_host": os.environ["SMTP_HOST"],
|
"smtp_host": os.environ.get("SMTP_HOST", imap_host),
|
||||||
"smtp_port": int(os.environ.get("SMTP_PORT", "587")),
|
"smtp_port": int(os.environ.get("SMTP_PORT", "587")),
|
||||||
"smtp_username": os.environ["SMTP_USERNAME"],
|
"smtp_username": os.environ.get(
|
||||||
"smtp_password": os.environ["SMTP_PASSWORD"],
|
"SMTP_USERNAME", os.environ["IMAP_USERNAME"]
|
||||||
|
),
|
||||||
|
"smtp_password": os.environ.get(
|
||||||
|
"SMTP_PASSWORD", os.environ["IMAP_PASSWORD"]
|
||||||
|
),
|
||||||
"watch_folders": ["INBOX"],
|
"watch_folders": ["INBOX"],
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
required = (
|
required = ("imap_host", "imap_username", "imap_password")
|
||||||
"imap_host",
|
|
||||||
"imap_username",
|
|
||||||
"imap_password",
|
|
||||||
"smtp_host",
|
|
||||||
"smtp_username",
|
|
||||||
"smtp_password",
|
|
||||||
)
|
|
||||||
for i, acc in enumerate(accounts):
|
for i, acc in enumerate(accounts):
|
||||||
acc.setdefault("id", f"account-{i}")
|
acc.setdefault("id", f"account-{i}")
|
||||||
acc.setdefault("imap_port", 993)
|
acc.setdefault("imap_port", 993)
|
||||||
acc.setdefault("smtp_port", 587)
|
|
||||||
acc.setdefault("watch_folders", ["INBOX"])
|
acc.setdefault("watch_folders", ["INBOX"])
|
||||||
|
# SMTP falls back to IMAP if not specified
|
||||||
|
acc.setdefault("smtp_host", acc.get("imap_host"))
|
||||||
|
acc.setdefault("smtp_port", 587)
|
||||||
|
acc.setdefault("smtp_username", acc.get("imap_username"))
|
||||||
|
acc.setdefault("smtp_password", acc.get("imap_password"))
|
||||||
for field in required:
|
for field in required:
|
||||||
if field not in acc:
|
if field not in acc:
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
|
|||||||
Reference in New Issue
Block a user