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
..
2026-01-19 14:12:36 +04:00
2026-02-03 02:06:51 +05:30
2026-01-21 13:39:07 +05:30
2020-03-11 00:02:15 +05:30
2025-08-11 21:44:38 -07:00
2026-02-03 02:06:51 +05:30
2020-03-11 00:02:15 +05:30
2025-11-18 18:20:58 -08:00
2024-04-04 21:16:49 +05:30
2025-06-03 12:01:17 +05:30
2025-08-20 20:23:42 +02:00
2025-12-17 07:54:50 -08:00
2026-02-02 11:59:51 +05:30
2025-07-16 09:04:02 +05:30
2024-02-07 13:36:04 +04:00
2025-08-22 12:41:38 -07:00
2025-11-17 16:09:36 +05:30
2026-01-14 18:00:12 +05:30
2023-02-15 16:33:31 -08:00
2026-01-23 22:23:41 -08:00
2026-01-15 19:53:57 -08:00
2026-01-27 11:36:20 +04:00
2025-10-06 10:41:26 -07:00
2024-01-18 17:48:30 +05:30
2023-10-03 22:18:57 -07:00
2025-05-21 19:40:07 +05:30
2022-05-16 13:59:59 +05:30
2025-08-18 19:15:21 -07:00
2023-08-15 19:55:19 -07:00
2026-01-13 16:32:02 +04:00
2025-11-17 21:55:12 -08:00
2020-06-12 23:12:47 +05:30
2022-03-24 15:38:28 +05:30
2020-09-26 02:32:34 +05:30
2023-06-25 18:49:49 +05:30
2025-04-02 20:26:55 -07:00
2022-08-10 13:46:46 +02:00
2026-02-02 15:52:53 +05:30
2025-01-14 16:15:47 -08:00
2021-07-28 19:36:51 +05:30
2024-03-07 11:13:01 +05:30
2026-01-12 13:15:40 +05:30
2022-01-11 19:00:00 -08:00
2021-11-18 10:32:29 +05:30
2026-01-07 19:36:29 -08:00
2022-07-04 20:29:44 +05:30
2025-11-13 12:46:55 +05:30
2025-10-08 07:53:43 -07:00
2023-08-15 19:55:19 -07:00
2025-02-20 21:28:38 -08:00
2026-01-15 19:53:57 -08:00
2026-01-06 15:23:54 +05:30
2022-10-12 14:55:59 -07:00