Vishnu Narayanan
c884cdefde
feat: add per-account daily rate limit for outbound emails (#13411)
Introduce a daily cap on non-channel outbound emails to prevent abuse.
Fixes https://linear.app/chatwoot/issue/CW-6418/ses-incident-jan-28
## Type of change
- [x] New feature (non-breaking change which adds functionality)
- [x] Breaking change (fix or feature that would cause existing
functionality not to work as expected)
## Summary
- Adds a Redis-based daily counter to rate limit outbound emails per
account, preventing email abuse
- Covers continuity emails (WebWidget/API), conversation transcripts,
and agent notifications
- Email channel replies are excluded (paid feature, not abusable)
- Adds account suspension check in `ConversationReplyMailer` to block
already-queued emails for suspended accounts
## Limit Resolution Hierarchy
1. Per-account override (`account.limits['emails']`) — SuperAdmin
configurable
2. Enterprise plan-based (`ACCOUNT_EMAILS_PLAN_LIMITS`
InstallationConfig)
3. Global default (`ACCOUNT_EMAILS_LIMIT` InstallationConfig, default:
100)
4. Fallback (`ChatwootApp.max_limit` — effectively unlimited)
## Enforcement Points
| Path | Where | Behavior |
|------|-------|----------|
| WebWidget/API continuity |
`SendEmailNotificationService#should_send_email_notification?` |
Silently skipped |
| Widget transcript | `Widget::ConversationsController#transcript` |
Returns 429 |
| API transcript | `ConversationsController#transcript` | Returns 429 |
| Agent notifications | `Notification::EmailNotificationService#perform`
| Silently skipped |
| Email channel replies | Not rate limited | Paid feature |
| Suspended accounts | `ConversationReplyMailer` | Blocked at mailer
level |
2026-02-03 02:06:51 +05:30
..
2025-05-20 20:45:39 -07:00
2025-11-17 10:08:25 +05:30
2025-09-18 14:17:54 +05:30
2025-03-24 16:04:49 -07:00
2025-11-24 17:47:00 -08:00
2026-01-28 14:51:24 -08:00
2025-05-28 09:46:59 +05:30
2024-02-21 18:51:00 +05:30
2025-10-21 16:36:37 -07:00
2021-06-08 22:45:01 +05:30
2025-06-11 23:39:47 +05:30
2024-10-22 23:18:30 -07:00
2024-06-11 14:22:03 +05:30
2024-06-11 14:22:03 +05:30
2025-12-04 18:53:50 +05:30
2026-01-28 19:25:20 +05:30
2021-09-21 10:16:32 +05:30
2025-09-22 17:05:25 +05:30
2025-06-13 11:57:11 +05:30
2025-06-11 13:16:44 -04:00
2026-01-21 13:39:07 +05:30
2025-04-02 20:26:55 -07:00
2025-11-10 20:47:18 +05:30
2026-01-15 22:16:00 -08:00
2026-02-03 02:06:51 +05:30
2025-09-18 20:19:24 +05:30
2024-06-11 14:22:03 +05:30
2026-02-03 02:06:51 +05:30
2025-08-11 12:03:48 +05:30
2025-12-05 13:02:53 -08:00
2026-02-02 15:52:53 +05:30
2026-01-13 16:32:02 +04:00
2025-06-11 23:39:47 +05:30
2026-02-02 16:50:35 +05:30
2025-09-18 20:19:24 +05:30
2025-05-23 12:58:13 +05:30
2026-02-02 11:59:51 +05:30
2024-06-11 14:22:03 +05:30
2025-09-18 20:19:24 +05:30
2026-01-15 22:16:00 -08:00
2026-01-13 16:32:02 +04:00
2026-01-13 16:32:02 +04:00
2025-03-03 16:38:22 +05:30
2023-03-14 09:09:57 -07:00
2026-01-07 15:30:49 +05:30