Safe Haskell | None |
---|---|
Language | Haskell98 |
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)
- type Username = String
- type Password = String
- type ServerName = String
- data ConnectionSettings
- data Authentication = Authentication AuthType Username Password
- data SMTPServer = SMTPServer (Maybe Authentication) ConnectionSettings
- data FormatMail = FormatMail {
- formatFrom :: Feed -> FeedElement -> Address
- formatSubject :: Feed -> FeedElement -> Text
- formatBody :: Feed -> FeedElement -> Text
- formatTo :: Feed -> FeedElement -> [Address]
- data SendMailSettings = SendMailSettings (Feed -> FeedElement -> SMTPServer) FormatMail
- mkCoHooks :: MonadIO m => SendMailSettings -> CoHooksF m SendMailSettings
- defaultFormatFrom :: Feed -> FeedElement -> Address
- defaultFormatSubject :: Feed -> FeedElement -> Text
- defaultFormatBody :: Feed -> FeedElement -> Text
- authenticate_ :: SMTPConnection -> Authentication -> IO Bool
- withSMTPConnection :: SMTPServer -> (SMTPConnection -> IO a) -> IO a
- buildMail :: FormatMail -> UTCTime -> TimeZone -> Feed -> FeedElement -> Mail
Settings
type ServerName = String Source #
data ConnectionSettings Source #
How to connect to the SMTP server
data Authentication Source #
How to authenticate to the SMTP server
data SMTPServer Source #
data FormatMail Source #
How to format outgoing mails from feed elements
FormatMail | |
|
data SendMailSettings Source #
Interpreter
mkCoHooks :: MonadIO m => SendMailSettings -> CoHooksF m SendMailSettings Source #
Interpreter for HooksF
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
authenticate_ :: SMTPConnection -> Authentication -> IO Bool Source #
withSMTPConnection :: SMTPServer -> (SMTPConnection -> IO a) -> IO a Source #
buildMail :: FormatMail -> UTCTime -> TimeZone -> Feed -> FeedElement -> Mail Source #
Build mail from a given feed