- newtype Boundary = Boundary {
- unBoundary :: Text
- data Mail = Mail {
- mailHeaders :: [(ByteString, Text)]
- mailParts :: [Alternatives]
- type Alternatives = [Part]
- data Part = Part {
- partType :: Text
- partEncoding :: Encoding
- partFilename :: Maybe Text
- partHeaders :: Headers
- partContent :: ByteString
- data Encoding
- renderMail :: RandomGen g => g -> Mail -> (ByteString, g)
- renderMail' :: Mail -> IO ByteString
- sendmail :: ByteString -> IO ()
- renderSendMail :: Mail -> IO ()
- simpleMail :: Text -> Text -> Text -> Text -> Text -> [(Text, FilePath)] -> IO Mail
- randomString :: RandomGen d => Int -> d -> (String, d)
- quotedPrintable :: Bool -> ByteString -> Builder
Datatypes
MIME boundary between parts of a message.
An entire mail message.
|
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.
Render a message
renderMail :: RandomGen g => g -> Mail -> (ByteString, g)Source
renderMail' :: Mail -> IO ByteStringSource
Like renderMail
, but generates a random boundary.
Sending messages
sendmail :: ByteString -> IO ()Source
Send a fully-formed email message via the sendmail executable.
High-level Mail
creation
:: Text | to |
-> Text | 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.
Utilities
randomString :: RandomGen d => Int -> d -> (String, d)Source
Generates a random sequence of alphanumerics of the given length.
quotedPrintable :: Bool -> ByteString -> BuilderSource
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.