-- Track whether each sent email is actually present in Gmail's Sent folder.
-- SMTP success only proves Gmail accepted the message; landing in Sent is
-- the stronger guarantee we can independently confirm via IMAP.

ALTER TABLE billing_communications
  ADD COLUMN email_verified_in_gmail TINYINT(1) DEFAULT 0,
  ADD COLUMN email_verified_at DATETIME DEFAULT NULL,
  ADD COLUMN email_verification_attempts INT DEFAULT 0;

-- Index supports the auto-retry sweep that finds rows with email_sent=1 but
-- not yet verified, scoped to a billing_period.
CREATE INDEX idx_verification_lookup
  ON billing_communications (billing_period, email_sent, email_verified_in_gmail);
