Safe Haskell | None |
---|---|
Language | Haskell98 |
- newtype Boundary = Boundary {
- unBoundary :: Text
- data Mail = Mail {}
- emptyMail :: Address -> Mail
- data Address = Address {
- addressName :: Maybe Text
- addressEmail :: Text
- type Alternatives = [Part]
- data Part = Part {}
- data Encoding
- type Headers = [(ByteString, Text)]
- renderMail :: RandomGen g => g -> Mail -> (ByteString, g)
- renderMail' :: Mail -> IO ByteString
- sendmail :: ByteString -> IO ()
- sendmailCustom :: FilePath -> [String] -> ByteString -> IO ()
- renderSendMail :: Mail -> IO ()
- renderSendMailCustom :: FilePath -> [String] -> Mail -> IO ()
- simpleMail :: Address -> Address -> Text -> Text -> Text -> [(Text, FilePath)] -> IO Mail
- simpleMail' :: Address -> Address -> Text -> Text -> Mail
- addPart :: Alternatives -> Mail -> Mail
- addAttachment :: Text -> FilePath -> Mail -> IO Mail
- addAttachments :: [(Text, FilePath)] -> Mail -> IO Mail
- htmlPart :: Text -> Part
- plainPart :: Text -> Part
- randomString :: RandomGen d => Int -> d -> (String, d)
- quotedPrintable :: Bool -> ByteString -> Builder
Datatypes
MIME boundary between parts of a message.
An entire mail message.
|
emptyMail :: Address -> Mail Source
A mail message with the provided from
address and no other
fields filled in.
type Alternatives = [Part] Source
Multiple alternative representations of the same data. For example, you could provide a plain-text and HTML version of a message.
A single part of a multipart message.
Part | |
|
How to encode a single part. You should use Base64
for binary data.
type Headers = [(ByteString, Text)] Source
Render a message
renderMail :: RandomGen g => g -> Mail -> (ByteString, g) Source
renderMail' :: Mail -> IO ByteString Source
Like renderMail
, but generates a random boundary.
Sending messages
sendmail :: ByteString -> IO () Source
Send a fully-formed email message via the default sendmail executable with default options.
:: FilePath | sendmail executable path |
-> [String] | sendmail command-line options |
-> ByteString | mail message as lazy bytestring |
-> IO () |
Send a fully-formed email message via the specified sendmail executable with specified options.
renderSendMail :: Mail -> IO () Source
Render an email message and send via the default sendmail executable with default options.
:: FilePath | sendmail executable path |
-> [String] | sendmail command-line options |
mail to render and send | |
-> IO () |
Render an email message and send via the specified sendmail executable with specified options.
High-level Mail
creation
:: Address | to |
-> Address | from |
-> Text | subject |
-> Text | plain body |
-> Text | HTML body |
-> [(Text, FilePath)] | content type and path of attachments |
-> IO Mail |
A simple interface for generating an email with HTML and plain-text alternatives and some file attachments.
Note that we use lazy IO for reading in the attachment contents.
A simple interface for generating an email with only plain-text body.
Utilities
addPart :: Alternatives -> Mail -> Mail Source
Add an Alternative
to the Mail
s parts.
To e.g. add a plain text body use > addPart [plainPart body] (emptyMail from)
addAttachment :: Text -> FilePath -> Mail -> IO Mail Source
Add an attachment from a file and construct a Part
.
randomString :: RandomGen d => Int -> d -> (String, d) Source
Generates a random sequence of alphanumerics of the given length.
quotedPrintable :: Bool -> ByteString -> Builder Source
The first parameter denotes whether the input should be treated as text. If treated as text, then CRs will be stripped and LFs output as CRLFs. If binary, then CRs and LFs will be escaped.