feat(limits): new accounts start at 200 emails/day and grow over 14 days
A new team paid for Basic and, within the hour, sent one "test" message to 2,946 different addresses: paid teams get the full 10,000/day from day 0. Over the past year, 31 teams sent email in their first 14 days; every lasting customer stayed under 150/day, and the only ones above were one-off blasts (6,116, 2,952, 2,943 and 780 on day 0–1).
What changes
- Paid teams in their first 14 days get a lower daily cap: 200/day (days 0–2), 1,000 (days 3–6), 5,000 (days 7–13), then the plan's normal limit.
- It only grows with clean sending: if the team's bounces or complaints would trip the existing sending rules (
judgeCounts), it stays at 200. - Existing customers are not affected: teams created before 2026-11-28 00:00 UTC are grandfathered (no team was created since then), and older teams return before any query.
- Teams whose
dailyEmailLimitan admin set by hand (anything other than the 10,000 default) skip the ramp, e.g. a business moving existing volume over on day one. - At the cap, the email fails like the existing daily limit (
EMAIL_DAILY_LIMIT_REACHED), and the team gets a once-a-day email explaining the schedule and that they can reply for more. Capped campaign emails fail the same way (deliberate; same as the existing daily limit).
How
new-sender-ramp.ts: pure rules + the notice text.LimitService.checkEmailLimit(teamId, recipients, emailId): the queue passes the email id. Each send atomically claims a slot in a Redis set per team per UTC send day (Lua: already-claimed retries reuse their slot; concurrent workers can't take the last one twice). Verified on Redis 7: 500 concurrent claims at a limit of 200 → exactly 200.- Lifetime counts are cached for 5 minutes. The whole check is bounded at 2 s and fails open (logged), so a hung Redis or DB never holds a queue worker. The notice is sent in the background.
No migration, no new settings or env vars.
Verification: pnpm test:web (600 tests) passes, production build OK, Astra review addressed (concurrency, send-day accounting, worker stalls, fail-open, grandfathering).
Ask Polylane for an impact assessment of this pull request:
Summary by cubic
Adds a staged sending cap for new paid accounts so a bought or scraped list can't be blasted on day one. New teams start at 200 emails/day, grow to 1,000 then 5,000, and reach the plan's normal limit after 14 days—only if bounces and complaints stay within the existing sending rules.
- Teams created before 2026-11-28 keep their current limits, and teams whose daily limit an admin set by hand skip the ramp.
- Counts mailboxes (to, cc, bcc) as Nodemailer sends them—one entry can hold several addresses—so a large bcc can't slip past the cap.
- At the cap, sends fail with the existing
EMAIL_DAILY_LIMIT_REACHEDerror and the team gets a once-a-day explanatory email. - Each send atomically claims a slot in a per-team per-UTC-day Redis set; retries reuse their slot.
- The check resolves against the UTC day it started, is bounded at 2 seconds, and fails open if Redis or the DB hangs.
No migration or new settings required.
Summary by CodeRabbit
- New Features
- Eligible newly created paid teams on the default daily limit receive staged daily recipient caps during their first 14 days: 200 initially, rising to 1,000 and then 5,000. High bounce or complaint levels may keep the cap at 200.
- Recipient counts include addresses in To, Cc, and Bcc.
- When a team reaches its daily cap, it receives an email explaining the limit and next steps. The notice is sent at most once per day.
- Retrying an email already counted toward the daily cap does not use another slot.