Add SMTP email sending capability to Ava, gated by approval queue.
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).
pass ben@bensima.com (already implemented)Only sends emails that have been approved in the outreach queue.
{
"name": "email_send",
"parameters": {
"draft_id": "string (required) - ID of approved draft"
}
}
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
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)