HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulemime-mail-0.5.1Haskell2010

Network.Mail.Mime

  • 11 types
  • 27 values

Datatypes

12 declarations
datadata Mail
#

An entire mail message.

Constructors

Instances3Show, Generic, Rep
valueemptyMail :: Address -> Mail
#

A mail message with the provided from address and no other fields filled in.

datadata Address
#
Instances5Eq, Show, IsString, Generic, Rep
typetype Alternatives = [Part]
#

Multiple alternative representations of the same data. For example, you could provide a plain-text and HTML version of a message.

datadata Part
#

A single part of a multipart message.

Constructors

Instances4Eq, Show, Generic, Rep
datadata PartContent
#

NestedParts are for multipart-related: One HTML part and some inline images

Instances4Eq, Show, Generic, Rep
datadata Disposition
#
Instances4Eq, Show, Generic, Rep
datadata Encoding
#

How to encode a single part. You should use Base64 for binary data.

Instances4Eq, Show, Generic, Rep

Render a message

2 declarations

Sending messages

5 declarations
valuesendmail :: ByteString -> IO ()
#

Send a fully-formed email message via the default sendmail executable with default options.

valuesendmailCustom
  1. :: FilePath

    sendmail executable path

  2. -> [String]

    sendmail command-line options

  3. -> ByteString

    mail message as lazy bytestring

  4. -> IO ()
#

Send a fully-formed email message via the specified sendmail executable with specified options.

valuerenderSendMail :: Mail -> IO ()
#

Render an email message and send via the default sendmail executable with default options.

valuerenderSendMailCustom
  1. :: FilePath

    sendmail executable path

  2. -> [String]

    sendmail command-line options

  3. -> Mail

    mail to render and send

  4. -> IO ()
#

Render an email message and send via the specified sendmail executable with specified options.

High-level Mail creation

4 declarations
valuesimpleMail
  1. :: Address

    to

  2. -> Address

    from

  3. -> Text

    subject

  4. -> Text

    plain body

  5. -> Text

    HTML body

  6. -> [(Text, FilePath)]

    content type and path of attachments

  7. -> 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.

valuesimpleMailWithImages
  1. :: [Address]

    to (multiple)

  2. -> Address

    from

  3. -> Text

    subject

  4. -> Text

    plain body

  5. -> Text

    HTML body

  6. -> [InlineImage]
  7. -> [(Text, FilePath)]

    content type and path of attachments

  8. -> IO Mail
#

An interface for generating an email with HTML and plain-text alternatives, some file attachments, and inline images. Note that we use lazy IO for reading in the attachment and inlined images. Inline images can be referred to from the HTML content using the src="cid:{{CONTENT-ID}}" syntax, where CONTENT-ID is the filename of the image.

Since 0.5.0

Utilities

15 declarations
valueaddPart :: Alternatives -> Mail -> Mail
#

Add an Alternative to the Mails parts.

To e.g. add a plain text body use > addPart [plainPart body] (emptyMail from)

valuerenderAddress :: Address -> Text
#

Format an E-Mail address according to the name-addr form (see: RFC5322 § 3.4 "Address specification", i.e: [display-name] <addr-spec>) This can be handy for adding custom headers that require such format.

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.