| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
Imm.Hooks.SendMail
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)- 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 #
data ConnectionSettings #
How to connect to the SMTP server
Constructors
| Plain ServerName PortNumber | |
| Ssl ServerName Settings | |
| StartTls ServerName Settings |
Instances
data Authentication #
How to authenticate to the SMTP server
Constructors
| Authentication AuthType Username Password |
Instances
data FormatMail #
How to format outgoing mails from feed elements
Constructors
| FormatMail | |
Fields
| |
data SendMailSettings #
Constructors
| SendMailSettings (Feed -> FeedElement -> SMTPServer) FormatMail |
Interpreter
mkCoHooks :: MonadIO m => SendMailSettings -> CoHooksF m SendMailSettings #
Interpreter for HooksF
defaultFormatFrom :: Feed -> FeedElement -> Address #
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 #
Fill mail subject with the element title
defaultFormatBody :: Feed -> FeedElement -> Text #
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 #
withSMTPConnection :: SMTPServer -> (SMTPConnection -> IO a) -> IO a #
buildMail :: FormatMail -> UTCTime -> TimeZone -> Feed -> FeedElement -> Mail #
Build mail from a given feed