Safe Haskell | None |
---|
Network.Mail.Mime
- newtype Boundary = Boundary {
- unBoundary :: Text
- data Mail = Mail {
- mailFrom :: Address
- mailTo :: [Address]
- mailCc :: [Address]
- mailBcc :: [Address]
- mailHeaders :: [(ByteString, Text)]
- mailParts :: [Alternatives]
- emptyMail :: Address -> Mail
- data Address = Address {
- addressName :: Maybe Text
- addressEmail :: Text
- 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 ()
- sendmailCustom :: FilePath -> [String] -> ByteString -> IO ()
- renderSendMail :: Mail -> IO ()
- renderSendMailCustom :: FilePath -> [String] -> Mail -> IO ()
- simpleMail :: Address -> Address -> Text -> Text -> Text -> [(Text, FilePath)] -> IO Mail
- randomString :: RandomGen d => Int -> d -> (String, d)
- quotedPrintable :: Bool -> ByteString -> Builder
Datatypes
newtype Boundary
MIME boundary between parts of a message.
Constructors
Boundary | |
Fields
|
data Mail
An entire mail message.
Constructors
Fields
|
A mail message with the provided from
address and no other
fields filled in.
data Address
Constructors
Address | |
Fields
|
type Alternatives = [Part]
Multiple alternative representations of the same data. For example, you could provide a plain-text and HTML version of a message.
data Part
A single part of a multipart message.
Constructors
Part | |
Fields
|
data Encoding
How to encode a single part. You should use Base64
for binary data.
Constructors
None | |
Base64 | |
QuotedPrintableText | |
QuotedPrintableBinary |
Render a message
renderMail :: RandomGen g => g -> Mail -> (ByteString, g)
renderMail' :: Mail -> IO ByteString
Like renderMail
, but generates a random boundary.
Sending messages
sendmail :: ByteString -> IO ()
Send a fully-formed email message via the default sendmail executable with default options.
Arguments
:: 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 ()
Render an email message and send via the default sendmail executable with default options.
Arguments
:: 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
Arguments
:: 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.
Utilities
randomString :: RandomGen d => Int -> d -> (String, d)
Generates a random sequence of alphanumerics of the given length.
quotedPrintable :: Bool -> ByteString -> Builder
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.