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-07-23 17:07:02 +04:00
2025-10-13 15:59:59 +05:30
2023-05-04 15:44:16 +05:30
2025-11-17 10:08:25 +05:30
2025-09-10 20:08:06 +05:30
2021-07-14 12:24:09 +05:30
2025-08-24 10:05:15 +05:30
2025-10-30 15:28:28 +05:30
2026-01-15 22:00:09 -08:00
2025-04-29 09:14:00 +05:30
2025-08-29 15:10:56 -07:00
2026-01-28 19:25:20 +05:30
2021-09-21 10:16:32 +05:30
2025-11-18 14:28:56 +05:30
2026-01-28 17:35:13 +05:30
2026-02-02 15:52:53 +05:30
2025-02-11 00:33:45 -08:00
2024-01-18 19:27:18 +04:00
2024-05-08 08:55:31 +05:30
2023-03-14 09:09:57 -07:00
2026-02-03 02:06:51 +05:30
2026-01-09 15:11:19 -08:00
2025-12-10 12:28:47 +05:30
2023-05-04 15:44:16 +05:30
2025-04-29 09:14:00 +05:30
2022-07-26 12:41:22 +05:30
2024-01-24 14:18:21 +04:00
2024-01-24 14:18:21 +04:00
2025-12-17 07:54:50 -08:00
2023-10-08 17:55:03 +05:30
2026-01-28 17:35:13 +05:30
2023-11-04 12:26:28 +05:30