imm-1.2.1.0: Execute arbitrary actions for each unread element of RSS/Atom feeds

Safe HaskellNone
LanguageHaskell98

Imm.Hooks.SendMail

Contents

Description

Hooks interpreter that sends a mail via a SMTP server for each element. You may want to consult Network.HaskellNet.SMTP, Network.HaskellNet.SMTP.SSL and Network.Mail.Mime modules for additional information.

Here is an example configuration:

sendmail :: SendMailSettings
sendmail = SendMailSettings smtpServer formatMail

formatMail :: FormatMail
formatMail = FormatMail
  (\a b -> (defaultFormatFrom a b) { addressEmail = "user@host" } )
  defaultFormatSubject
  defaultFormatBody
  (\_ _ -> [Address Nothing "user@host"])

smtpServer :: Feed -> FeedElement -> SMTPServer
smtpServer _ _ = SMTPServer
  (Just $ Authentication PLAIN "user" "password")
  (StartTls "smtp.server" defaultSettingsSMTPSTARTTLS)

Synopsis

Settings

data FormatMail Source #

How to format outgoing mails from feed elements

Constructors

FormatMail 

Fields

Interpreter

defaultFormatFrom :: Feed -> FeedElement -> Address Source #

Fill addressName with the feed title and, if available, the authors' names.

This function leaves addressEmail empty. You are expected to fill it adequately, because many SMTP servers enforce constraints on the From: email.

defaultFormatSubject :: Feed -> FeedElement -> Text Source #

Fill mail subject with the element title

defaultFormatBody :: Feed -> FeedElement -> Text Source #

Fill mail body with:

  • a list of links associated to the element
  • the element's content or description/summary

Low-level helpers

buildMail :: FormatMail -> UTCTime -> TimeZone -> Feed -> FeedElement -> Mail Source #

Build mail from a given feed