Default allow_send to false — sending must be explicitly enabled
This commit is contained in:
+4
-8
@@ -7,9 +7,9 @@ poke_api_key: "your-api-key-here"
|
||||
# MCP_API_KEY is set via environment variable (not in this file)
|
||||
# It secures the MCP server so only you can use it
|
||||
|
||||
# Global send toggle — set to false to disable send_email for all accounts
|
||||
# Agents can still use create_draft. Override per account with allow_send.
|
||||
allow_send: true
|
||||
# Global send toggle — disabled by default for safety.
|
||||
# Agents can still use create_draft. Enable per account with allow_send: true
|
||||
allow_send: false
|
||||
|
||||
accounts:
|
||||
# Minimal — SMTP falls back to IMAP host/credentials
|
||||
@@ -21,7 +21,7 @@ accounts:
|
||||
watch_folders:
|
||||
- INBOX
|
||||
|
||||
# Full — separate SMTP settings, send restrictions
|
||||
# Full — separate SMTP settings (only if different from IMAP)
|
||||
# - id: work
|
||||
# imap_host: imap.example.com
|
||||
# imap_port: 993
|
||||
@@ -31,9 +31,5 @@ accounts:
|
||||
# smtp_port: 587
|
||||
# smtp_username: "you@example.com"
|
||||
# smtp_password: "smtp-password"
|
||||
# allow_send: true
|
||||
# blocked_recipients: # agent cannot send to these addresses
|
||||
# - "ceo@company.com"
|
||||
# - "all-staff@company.com"
|
||||
# watch_folders:
|
||||
# - INBOX
|
||||
|
||||
+2
-15
@@ -86,7 +86,7 @@ def parse_accounts(config: dict) -> list[dict]:
|
||||
}
|
||||
]
|
||||
|
||||
global_allow_send = config.get("allow_send", True)
|
||||
global_allow_send = config.get("allow_send", False)
|
||||
required = ("imap_host", "imap_username", "imap_password")
|
||||
for i, acc in enumerate(accounts):
|
||||
acc.setdefault("id", f"account-{i}")
|
||||
@@ -603,24 +603,11 @@ async def send_email(
|
||||
accounts = ctx.lifespan_context["accounts"]
|
||||
acc = resolve_account(accounts, account_id)
|
||||
|
||||
if not acc.get("allow_send", True):
|
||||
if not acc.get("allow_send", False):
|
||||
return {
|
||||
"error": f"Sending is disabled for account '{acc['id']}'. Use create_draft instead."
|
||||
}
|
||||
|
||||
blocked = {addr.lower() for addr in acc.get("blocked_recipients", [])}
|
||||
if blocked:
|
||||
all_recipients = [a.strip().lower() for a in to.split(",")]
|
||||
if cc:
|
||||
all_recipients.extend(a.strip().lower() for a in cc.split(","))
|
||||
if bcc:
|
||||
all_recipients.extend(a.strip().lower() for a in bcc.split(","))
|
||||
denied = [r for r in all_recipients if r in blocked]
|
||||
if denied:
|
||||
return {
|
||||
"error": f"Sending to {', '.join(denied)} is blocked. Use create_draft instead."
|
||||
}
|
||||
|
||||
def _send():
|
||||
msg = MIMEMultipart("alternative") if html else MIMEText(body)
|
||||
if html:
|
||||
|
||||
Reference in New Issue
Block a user