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