SMTP email sending for Ava

t-265.5·WorkTask·
·
·
Parent:t-265·Created2 months ago·Updated2 months ago

Dependencies

Description

Edit

Add SMTP email sending capability to Ava, gated by approval queue.

Context

Ava needs to send outreach emails to potential PodcastItLater users. Emails must be approved by Ben before sending. This builds on the approval queue (t-265.3).

Requirements

1. SMTP Configuration

  • Use Ben's email: ben@bensima.com
  • SMTP server: bensima.com (same as IMAP in Email.hs)
  • Password via pass ben@bensima.com (already implemented)

2. New Tool: email_send

Only sends emails that have been approved in the outreach queue.

{
  "name": "email_send",
  "parameters": {
    "draft_id": "string (required) - ID of approved draft"
  }
}

3. Sending Logic

1. Look up draft in _/var/ava/outreach/approved/ 2. Verify status is 'approved' 3. Send via SMTP 4. Move draft to sent/ directory 5. Update status to 'sent' 6. Return success/failure

4. Email Format

  • From: ben@bensima.com
  • Reply-To: ben@bensima.com
  • Subject: from draft
  • Body: from draft (plain text)
  • Add footer: "Sent by Ava on behalf of Ben"

Implementation Notes

  • Add to Omni/Agent/Tools/Email.hs
  • Use HaskellNet-SSL for SMTP (: dep HaskellNet-SSL)
  • Follow existing IMAP patterns for connection handling
  • Log all sent emails for audit trail

SMTP Connection Pattern

import qualified Network.HaskellNet.SMTP.SSL as SMTPSSL

withSmtpConnection :: (SMTPConnection -> IO a) -> IO (Either Text a)
withSmtpConnection action = do
  pwResult <- getPassword
  case pwResult of
    Left err -> pure (Left err)
    Right pw -> do
      conn <- SMTPSSL.connectSMTPSSL "bensima.com"
      SMTPSSL.authenticate LOGIN "ben@bensima.com" (Text.unpack pw) conn
      result <- action conn
      SMTPSSL.closeSMTP conn
      pure (Right result)

Files to Modify

  • Omni/Agent/Tools/Email.hs (add email_send tool, SMTP functions)
  • Omni/Agent/Telegram.hs (add tool to agent)

Verification

  • bild Omni/Agent/Tools/Email.hs
  • bild --test Omni/Agent/Tools/Email.hs
  • Manual test: Create draft, approve, send, verify receipt

Timeline (2)

🔄[human]Open → InProgress2 months ago
🔄[human]InProgress → Done2 months ago