Menu

1 / 2

Background e-mail jobs that never send twice

DEV Community: csharp·Vinclora·about 9 hours ago
#5xOs11Ag
#devtocsharp#devto#dev#week#mail
Long article (1613 words) — no AI summary yet.
Reading 0:00
15s threshold

ClientsPlace sends a weekly "Client Pulse" digest to workspace owners and admins: which clients need attention, new feedback, and what changed since last week. It's a recurring Hangfire job on .NET with PostgreSQL behind it. One Monday it sent the same digest again, then again an hour later, and again an hour after that, until our mail provider blocked outgoing mail on the mailbox.

That mailbox carries every product's mail, not only digests. A block there also stops sign-up, invitation and billing e-mails. A nice-to-have weekly summary ended up stopping mail that really matters.

Here is what happened, and the rules we follow for mail jobs now.

The failure mode: throwing after the send

The original job looked roughly like this:

[ AutomaticRetry ( Attempts = 24 ) ] // retried hourly public async Task Run ( CancellationToken ct ) { foreach ( var user in recipients ) { if ( await db . DigestReceipts . AnyAsync ( r =& gt ; r . WorkspaceId == workspaceId & amp ; & amp ; r . UserId == user .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.