Skip to content

gmail.sendBatch — batch send with throttling and dryRun flag #51

@AojdevStudio

Description

@AojdevStudio

Summary

Implement gmail.sendBatch operation that sends multiple templated emails with per-recipient variable substitution, built-in throttling (500ms default), a dryRun flag for preview mode, and structured per-recipient results.

Context

  • Repository: ~/Projects/local-mcps/gdrive
  • GitHub: AojdevStudio/gdrive
  • Plan Doc: docs/plans/2026-03-10-email-outreach-features.md (Task 4)
  • Relevant Files: src/modules/gmail/batchSend.ts (new), src/sdk/spec.ts, src/sdk/runtime.ts
  • Related Issues: Depends on gmail.sendFromTemplate (renderTemplate), gmail.dryRun, sheets.readAsRecords

Current Behavior

N/A — new feature. Sending multiple emails requires individual sendMessage calls with no throttling or batch result tracking.

Expected Behavior

gmail.sendBatch accepts a template (subject + body), an array of recipient objects (each with variables), and options (dryRun, throttleMs). It iterates recipients, renders templates, sends (or previews if dryRun), respects throttle delay, and returns structured results: { sent: number, failed: number, results: [{to, status, messageId?, error?}] }.

Acceptance Criteria (max 3)

  • AC-1: Sends N emails with per-recipient variable substitution and returns structured results with sent/failed counts
  • AC-2: Throttling respects configurable delay between sends (default 500ms) to avoid Gmail rate limits
  • AC-3: When dryRun=true, returns rendered previews for all recipients without sending any emails

Scope

In scope: batchSend operation, throttle logic, dryRun integration, structured results, SDK spec + runtime, unit tests
Out of scope: Queue persistence, retry on failure, parallel sending, progress callbacks

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions