audit(outreach): forensic audit of blocked and provider-rejected outbound emails - #31
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced Sep 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Outbound cold outreach emails sent via connected mailboxes are being blocked or rejected by receiving mail servers, corporate email security gateways (e.g. Proofpoint, Mimecast, Microsoft Defender), and Google Workspace / Gmail API infrastructure. Currently, these rejections are improperly classified within the delivery ledger and do not trigger campaign safety halts, allowing campaigns to continue blasting messages and destroying sender domain reputation.
Investigation
Traced the complete outbound delivery path end-to-end:
Campaign->automation:workflow(apps/desktop/src/main/workers/plugins/automation.ts) & bulk outreach (outreach.ts).sdk.outreach.sendEmail-> API router ->EmailService.send()(apps/api/src/services/email/email.service.ts).apps/api/src/services/email/email-account.service.ts(enforcing Zero Outbound SMTP / direct Nodemailer elimination).GmailProvider.sendMessage()(apps/api/src/services/google/gmail.provider.ts).ReconciliationService.pollInbound()(apps/api/src/services/email/reconciliation.service.ts) andparseDsnReport()(packages/schema/src/utils/bounce-classifier.ts).apps/api/src/repositories/email-delivery/email-delivery.repository.ts.Findings
SMTP 554 5.7.1 spam and gateway rejections fall through
classifyEmailFailure()to genericPROVIDER, whichEmailService.sendmaps toNETWORK. This treats fatal reputation blocks as transient network hiccups, allowing repeated toxic sends.In
gmail.provider.ts, HTTP 400 (malformed MIME, header length, bad characters) is hardcoded asINVALID_RECIPIENT.EmailService.sendthen permanently suppresses the contact address asHARD_BOUNCEand corrupts the contact status toBOUNCED/INVALID.In
gmail.provider.ts, all HTTP 403 responses (daily sending quota exceeded, bulk sender abuse blocks) are hardcoded toMAILBOX_REAUTH_REQUIRED, falsely claiming OAuth credentials expired.GmailProviderthrowsSENDER_RATE_LIMITED(rate_limit), butEmailService.sendchecksPROVIDER_RATE_LIMITED(provider_rate_limited), skippingsetProviderCooldown().ReconciliationService.pollInbound()line 707 hardcodesfailureCategory: EmailFailureCategory.INVALID_RECIPIENT, discarding the parsed DSN classification (e.g.SPAM_REJECTION,POLICY_REJECTION).Neither
automation.tsnoroutreach.tspauses the campaign when provider or recipient rejections occur.Burst sending to dozens of contacts at the same company (e.g., 64 contacts at
@targetcompany.com) occurs without pacing, triggering gateway spam burst heuristics.VALID_DELIVERY_TRANSITIONSpermitsAMBIGUOUS -> SENDINGandFAILED -> SENDING, allowing blind duplicate sends without verifying provider-side acceptance.Evidence
docs/forensics/phase-5-item-a-outbound-provider-rejection-audit.mdapps/api/src/services/email/outbound-provider-rejection-audit.test.ts(8/8 passing).Root Cause
classifyEmailFailure()inemail.service.tslacks branches for SMTP 554, spam filters, and policy rejections, and does not integrate canonicalclassifyBounce().GmailProvider.sendMessage()uses coarse HTTP status code branching that conflates quota/abuse blocks with auth revocation (403) and malformed requests with invalid recipient addresses (400).Severity
CRITICAL (P0): Severe sender domain reputation destruction, false-positive lead suppression, and broken operator governance.
Recommended Remediation Boundary (Phase 6)
classifyEmailFailure()to delegate toclassifyBounce()in@leadforge/schema.GmailProvider.PROVIDER_RATE_LIMITED).ReconciliationService.AMBIGUOUS -> SENDINGre-dispatch).Tests / Verification
pnpm --filter api exec vitest run src/services/email/outbound-provider-rejection-audit.test.ts pnpm --filter api check-typesResult: 8 tests passed, 0 type errors.
Scope
Audit Only. No remediation code or provider modifications were implemented in this PR.
Related Issue
Fixes #24 (Audit Phase 5 Item A)