HORIZON HASKELLDocslts/ghc-9.14.x7a6c33e2026-10-12Search packagesCtrl K
Theme: |

GHC 9.14.1 · lts/ghc-9.14.x · 7a6c33e · 2026-10-12

Datatypes

datadata Mail

An entire mail message.

Constructors

Instances4Eq, Show, Generic, Rep
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

Sending messages

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

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

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.