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)
|
# 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
|
||||||
|
|
||||||
# Global send toggle — set to false to disable send_email for all accounts
|
# Global send toggle — disabled by default for safety.
|
||||||
# Agents can still use create_draft. Override per account with allow_send.
|
# Agents can still use create_draft. Enable per account with allow_send: true
|
||||||
allow_send: true
|
allow_send: false
|
||||||
|
|
||||||
accounts:
|
accounts:
|
||||||
# Minimal — SMTP falls back to IMAP host/credentials
|
# Minimal — SMTP falls back to IMAP host/credentials
|
||||||
@@ -21,7 +21,7 @@ accounts:
|
|||||||
watch_folders:
|
watch_folders:
|
||||||
- INBOX
|
- INBOX
|
||||||
|
|
||||||
# Full — separate SMTP settings, send restrictions
|
# Full — separate SMTP settings (only if different from IMAP)
|
||||||
# - id: work
|
# - id: work
|
||||||
# imap_host: imap.example.com
|
# imap_host: imap.example.com
|
||||||
# imap_port: 993
|
# imap_port: 993
|
||||||
@@ -31,9 +31,5 @@ accounts:
|
|||||||
# smtp_port: 587
|
# smtp_port: 587
|
||||||
# smtp_username: "you@example.com"
|
# smtp_username: "you@example.com"
|
||||||
# smtp_password: "smtp-password"
|
# smtp_password: "smtp-password"
|
||||||
# allow_send: true
|
|
||||||
# blocked_recipients: # agent cannot send to these addresses
|
|
||||||
# - "ceo@company.com"
|
|
||||||
# - "all-staff@company.com"
|
|
||||||
# watch_folders:
|
# watch_folders:
|
||||||
# - INBOX
|
# - 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")
|
required = ("imap_host", "imap_username", "imap_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}")
|
||||||
@@ -603,24 +603,11 @@ async def send_email(
|
|||||||
accounts = ctx.lifespan_context["accounts"]
|
accounts = ctx.lifespan_context["accounts"]
|
||||||
acc = resolve_account(accounts, account_id)
|
acc = resolve_account(accounts, account_id)
|
||||||
|
|
||||||
if not acc.get("allow_send", True):
|
if not acc.get("allow_send", False):
|
||||||
return {
|
return {
|
||||||
"error": f"Sending is disabled for account '{acc['id']}'. Use create_draft instead."
|
"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():
|
def _send():
|
||||||
msg = MIMEMultipart("alternative") if html else MIMEText(body)
|
msg = MIMEMultipart("alternative") if html else MIMEText(body)
|
||||||
if html:
|
if html:
|
||||||
|
|||||||
Reference in New Issue
Block a user