fix(email): add EMAIL_DISABLE_AUTO_REPLY env var guard - #30790
Conversation
Add environment variable EMAIL_DISABLE_AUTO_REPLY to pause IMAP polling and block all SMTP send operations (_send_email, _send_email_with_attachments, _send_email_with_file) while still receiving and processing inbound emails. When enabled (1/true/yes): - IMAP poll_loop is skipped during start_platform() with INFO log - All SMTP send methods return a disabled message ID and log a WARNING - Cron job triage (email_watch_hourly.py) is unaffected Use case: prevent unsolicited auto-replies while keeping inbound email processing and triage functional.
|
Good catch on the relation to #5717. The key difference is scope:
The use case here is preventing unsolicited auto-replies during debugging/testing windows — we want to stop all automated email activity (both sending and polling-triggered actions) while still receiving and triaging inbound mail. Consolidation into a unified suppression mechanism makes sense as a follow-up, but I think this PR is valuable standalone since it addresses a different operational need. Happy to discuss merging approaches if maintainers prefer. |
|
Thanks for addressing the operator need to prevent unintended email replies. The member discussion linking #5717 was useful context. This automated hermes-sweeper review is closing the PR as a configuration-direction mismatch:
A focused follow-up using a Closed as not-planned per standing maintainer policy ( Closed as not-planned per standing maintainer policy ( |
What does this PR do?
Add
EMAIL_DISABLE_AUTO_REPLYenvironment variable to pause IMAP polling and block all SMTP send operations while still receiving and processing inbound emails. This prevents unsolicited auto-replies while keeping inbound email processing and cron triage functional.Related Issue
Fixes #
Type of Change
Changes Made
gateway/platforms/email.py(+37/-3 lines)start_platform): Skip poll_loop creation whenEMAIL_DISABLE_AUTO_REPLY=1/true/yes, with INFO log explaining the pause._send_email(): Return disabled message ID, log WARNING with recipient and subject_send_email_with_attachments(): Return disabled message ID, log WARNING_send_email_with_file(): Return disabled message ID, log WARNING<hermes-disabled-{uuid}@{domain}>so callers don't crash.email_watch_hourly.py) is unaffected — inbound emails still processed.How to Test
EMAIL_DISABLE_AUTO_REPLY=1in environment or.envsystemctl --user restart hermes-gateway[Email] Platform PAUSED — IMAP polling disabled by EMAIL_DISABLE_AUTO_REPLYChecklist
Code
pytest tests/ -qand all tests passDocumentation & Housekeeping
Screenshots / Logs