Skip to content
besata
← All projects / 30
07 / Case study

Mail workflow

Email workflow with send approval and operation history

Mail workflow

A spreadsheet controls permission; a separate state layer handles delivery, copies and recovery.

Work verified against its source.
01 / The task

The mail server may accept a message before the spreadsheet status is saved. Simply running the script again can send a duplicate.

02 / The solution

A state machine connects Google Sheets, SMTP and IMAP. Permission is checked again before sending, while uncertain outcomes block blind retries.

  • Manual spreadsheet permission
  • Durable queue
  • Duplicate-send protection
  • Reply-thread matching
03

The spreadsheet stays the working interface

Permission belongs to a specific row and address. The current decision is checked again before transmission so cancellations and changed details take effect.

04

Send state and recovery

Delivery, the sent-folder copy and the spreadsheet update are tracked separately. A later failure must not trigger another send; an uncertain SMTP result requires reconciliation.

05

Reply tracking

The code reads IMAP headers, matches threads and checks senders. Automatic replies are excluded, and the cursor advances after saving. A live end-to-end check remains a separate task.

Context and limits +

The complete live reply-tracking cycle was not reverified. Delivery rates are not guaranteed, and this is not presented as a bulk-mail service.

Built with

Google SheetsPythonSQLiteSMTP / IMAP
Let’s discuss your idea ↗