Ten hours after they unsubscribed, my software emailed them again
Somebody booked a free trial at my gym on 27 August. Over the next nine days my software sent them four emails. On Saturday 5 September, at 1:32 in the afternoon, they asked to be taken off the list. Ten hours and twenty-seven minutes later, just after midnight, my software sent them a fifth one: "Your trial ends in 2 days. Don't lose access."
They complained. Then they complained again. That is the operator's account rather than a row I can show you, because the complaints came in by email and I never logged them into the platform. The rest of this is from the database.
The second complaint is the part worth sitting with. The first was about an email. The second was about being ignored, which is a different and more expensive thing for a small gym to be accused of. Persistence Athletics has 192 people in its members table. It cannot afford to be the business that keeps talking after you have asked it to stop.
Two tables, two ideas of what consent means
The gym's platform has a marketing engine and a member lifecycle. They were built at different times for different jobs, and they keep their people in different places.
The marketing engine works off a table called marketing_contacts. It holds 490 rows: leads, ex-members, people who filled in a form once. Each row has a status, and unsubscribed is one of the values it can take. When somebody asks to come off the list, that is the row that changes.
The member lifecycle works off the members table, because that is where trial dates and membership status live. Trial ending reminders, no-show follow-ups, post-trial offers, birthday emails: all of them start with a query against members.
Nothing joined the two. The unsubscribe wrote a status onto a marketing row, and the sender that emailed them ten hours later never looked at that table in its life.
old: an unsubscribe set a status on a marketing row, and the senders that decide whether a member may be emailed read a different table entirely.
new: the lifecycle and campaign senders pass one guard that checks the member flag and the marketing status before the message leaves.The timeline, from the rows
The communications table records three emails to this person before the unsubscribe: the trial booking confirmation on 27 August at 20:27 UTC, a no-show follow-up on 2 September at 19:00, and a half-price offer on 5 September at 19:00.
Two more emails do not appear there at all, and finding them is how I understood the shape of this. The cron that sends trial ending reminders lives in the billing cleanup route. It selects trial members, works out how many days are left, and if the answer is five or two it calls sendEmail and then writes a portal notification. It never writes a communications row, so the gym's own record of what it has said to a person is missing the exact email that caused the complaint.
I found it in the notifications table instead. Notification 3323, member 825, title "Trial ends in 2 days", created 2026-09-06 at 07:00:02 UTC. That row is written on the line after the email send, inside the same block, so its existence is my evidence that the email went. There is a matching one for the five-day reminder on 3 September.
The unsubscribe itself is a marketing_contacts row created 2026-09-05 at 20:32:51 UTC. Subtract one from the other and you get 10 hours, 27 minutes and 11 seconds. In Pacific time it reads worse: they asked at lunchtime on a Saturday and the next email left at midnight.
The trial ending reminder has no opt-out check of any kind. Not a member preference, not a marketing status, nothing. It is a query, a date comparison, and a send.
How many people this could have happened to
One bad email is an anecdote. The exposure is the finding.
Of the 490 rows in marketing_contacts, 27 are marked unsubscribed. Nine of those 27 people also exist as rows in the members table, which is what every lifecycle cron starts from. The other 18 are safe by accident: the marketing engine is the only thing that ever knew about them, and the marketing engine was reading the right table.
So nine people had asked the gym to stop and were still standing in front of every trial nudge, offer email and birthday message the platform sends. One of them found out.
A second number explains why. Fifty-two files in the app call sendEmail. Four of them consult the member preference module. That module is 245 lines and it is good: it separates marketing from transactional, treats an absent preference row as consent to send, and fails open so a broken lookup never silently swallows somebody's receipt. It was written on 14 August to close this same class of bug, after three members with the email toggle switched off kept receiving mail.
Four senders were classified as marketing when that module went in. The trial ending reminder was not one of them. It lives in a file called billing cleanup, sitting next to invoice housekeeping, so by the shape of the code it looks transactional. By the content of the email it is a sales message with a deadline in the subject line. Nobody miscategorised it on purpose. The classification was done by hand, once, and something marketing-shaped ended up on the wrong side of the line.
The fix, and why it is a hammer
The change is 49 lines across two files. A column, members.email_opt_out, and a guard inside sendEmail, the function the lifecycle and campaign senders pass through. Before a message leaves, the guard checks whether the recipient has that flag set or has an unsubscribed marketing row. If either is true the address is dropped, and if that leaves nobody, the send becomes a silent no-op. It fails open: if the lookup throws, mail goes out, because breaking everybody's email to protect one person is the worse outcome.
It shipped on Sunday 6 September at 11:03 Pacific and the service restarted six minutes later. I checked that rather than assuming it: the deployed HEAD is that commit and the built server bundle contains the guard's log line. Underneath it sits one more layer, a global suppression at SendGrid, which stops any script that never touches the app at all.
Correction, added 2026-09-08. When I first published this I wrote that sendEmail was the one function every email in the app passes through. That was the code comment's claim and I repeated it without testing it. It is not true. Grepping for the SendGrid endpoint directly finds four senders that never call sendEmail at all: subscription changes, the billing payment-update flow, rental emails and invoice emails. Those four still bypass the guard today. The fix covers the senders that caused this incident, which is the honest scope of it, and I have left the rest of the post as written rather than quietly restating what I claimed.
There is a second consequence I did not think through at the time. The guard blocks everything for an opted-out address, with no carve-out for transactional mail, and the portal's forgot-password route sends through sendEmail. So a member who unsubscribes can no longer receive a password reset. Silencing a marketing list should not lock somebody out of their own account, and that is now the more urgent of the two problems.
What this does not prove
I can prove exactly one wrong email. One. The other eight are exposure, not confirmed sends, and for most of them I could not check even if I wanted to, because the sender that caused this incident does not write to the communications log at all. If it happened to somebody else earlier this year, the platform has no memory of it.
I cannot date any of the other unsubscribes. I wanted to know how long each of the 27 had been exposed, and the updated_at column looked like it would answer that. It does not: 460 of the 490 rows carry today's date, because the nightly marketing sync touches every row whether or not anything changed. A timestamp that moves for reasons unrelated to the event you care about is not evidence, and I would have published a fiction if I had trusted it.
The guard has never actually silenced anybody. Since it shipped there are zero suppression events in the service journal. The trial reminder cron has run since the restart and sent normally to somebody who had not opted out, so the new code path does execute. It simply has not had anybody to protect yet. What I have is a mechanism, not a result.
The app is not the only thing that sends mail. There are 301 scripts in the deploy directory and 71 of them use SendGrid directly instead of going through the app: announcements, one-off follow-ups, event blasts. None of those pass the guard. They are covered only by the SendGrid-side suppression, so protection on those paths is manual and depends on somebody remembering it every single time.
The best argument against what I shipped
The guard blocks everything, and my own preference module says in writing that it should not.
That module has a list of message types that must never be gated: booking confirmations, waiver reminders, invoices, receipts, payment failures, password resets. The reasoning is one line and it is correct. An opt-out is not consent to be billed silently. If your card fails and the notice is suppressed because you once asked to stop getting marketing mail, you find out when your access stops working.
The new guard has no such carve-out. For the one member currently carrying the hard flag, a payment failure notice would be dropped on the floor. I shipped it knowing that, because the population holding that flag is one person who asked twice to be left alone and is not being charged for anything this week. That is a judgement about a specific person, not a policy, and it does not survive the second or third name landing on the list.
The honest version is that I traded one failure mode for another I have not had to pay for yet. The real fix is per-category consent wired to the toggles already sitting in the member portal, so "no marketing, yes receipts" is expressible. That was on the list before this happened, which is its own kind of answer.
The other argument against me is simpler. I fixed this exact class of bug on 14 August, wrote 245 lines and a long comment about it, and it happened again three weeks later through a door I had not thought to close. Building the preference module did not make the system respect preferences. It made four senders respect preferences.
What generalises
If your business sends automated email, the question is not whether you have an unsubscribe. It is how many places in your code can put a message in front of a customer, and how many of them ask permission first. Those are two different counts and the gap between them is your exposure. Mine was 52 and 4.
Second: check consent at one door on the way out, not at each caller. The caller you forget is by definition the one you were never going to remember.
Third, and this is the one that cost me: consent becomes a data-modelling problem the moment the same human exists as two rows in two tables. A lead who becomes a trial member is one person and two records, and neither record knows about the other. Every business with a marketing list and a customer database has this. Most of them find out the way I did.
If your systems are sending things you would not have chosen to send, that is the sort of problem I take on at Autosterea.
First published on ravikantdewangan.com.

