-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Compose MIME email messages.
--   
--   This package provides some high-level datatypes for declaring MIME
--   email messages, functions for automatically composing these into
--   bytestrings, and the ability to send bytestrings via the sendmail
--   executable. You can also use any other library you wish to send via
--   different methods, eg directly to SMTP.
@package mime-mail
@version 0.4.1.2

module Network.Mail.Mime

-- | MIME boundary between parts of a message.
newtype Boundary
Boundary :: Text -> Boundary
unBoundary :: Boundary -> Text

-- | An entire mail message.
data Mail
Mail :: Address -> [Address] -> [Address] -> [Address] -> [(ByteString, Text)] -> [Alternatives] -> Mail
mailFrom :: Mail -> Address
mailTo :: Mail -> [Address]
mailCc :: Mail -> [Address]
mailBcc :: Mail -> [Address]

-- | Other headers, excluding from, to, cc and bcc.
mailHeaders :: Mail -> [(ByteString, Text)]

-- | A list of different sets of alternatives. As a concrete example:
--   
--   
--   mailParts = [ [textVersion, htmlVersion], [attachment1], [attachment1]]
--   
--   
--   Make sure when specifying alternatives to place the most preferred
--   version last.
mailParts :: Mail -> [Alternatives]

-- | A mail message with the provided from address and no other
--   fields filled in.
emptyMail :: Address -> Mail
data Address
Address :: Maybe Text -> Text -> Address
addressName :: Address -> Maybe Text
addressEmail :: Address -> Text

-- | Multiple alternative representations of the same data. For example,
--   you could provide a plain-text and HTML version of a message.
type Alternatives = [Part]

-- | A single part of a multipart message.
data Part
Part :: Text -> Encoding -> Maybe Text -> Headers -> ByteString -> Part

-- | content type
partType :: Part -> Text
partEncoding :: Part -> Encoding

-- | The filename for this part, if it is to be sent with an attachemnt
--   disposition.
partFilename :: Part -> Maybe Text
partHeaders :: Part -> Headers
partContent :: Part -> ByteString

-- | How to encode a single part. You should use Base64 for binary
--   data.
data Encoding
None :: Encoding
Base64 :: Encoding
QuotedPrintableText :: Encoding
QuotedPrintableBinary :: Encoding

-- | Render a Mail with a given RandomGen for producing
--   boundaries.
renderMail :: RandomGen g => g -> Mail -> (ByteString, g)

-- | Like renderMail, but generates a random boundary.
renderMail' :: Mail -> IO ByteString

-- | Send a fully-formed email message via the default sendmail executable
--   with default options.
sendmail :: ByteString -> IO ()

-- | Send a fully-formed email message via the specified sendmail
--   executable with specified options.
sendmailCustom :: FilePath -> [String] -> ByteString -> IO ()

-- | Render an email message and send via the default sendmail executable
--   with default options.
renderSendMail :: Mail -> IO ()

-- | Render an email message and send via the specified sendmail executable
--   with specified options.
renderSendMailCustom :: FilePath -> [String] -> Mail -> IO ()

-- | 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.
simpleMail :: Address -> Address -> Text -> Text -> Text -> [(Text, FilePath)] -> IO Mail

-- | Generates a random sequence of alphanumerics of the given length.
randomString :: RandomGen d => Int -> d -> (String, d)

-- | 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.
quotedPrintable :: Bool -> ByteString -> Builder
instance Random Boundary
