mime-mail-0.0.0: Compose MIME email messages.

Network.Mail.Mime

Contents

Synopsis

Datatypes

newtype Boundary Source

MIME boundary between parts of a message.

Constructors

Boundary 

Fields

unBoundary :: String
 

Instances

data Mail Source

An entire mail message.

Constructors

Mail 

Fields

mailHeaders :: [(String, String)]

All headers, including to, from subject. | 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 :: [Alternatives]
 

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.

data Part Source

A single part of a multipart message.

Constructors

Part 

Fields

partType :: String

content type

partEncoding :: Encoding
 
partFilename :: Maybe String

The filename for this part, if it is to be sent with an attachemnt disposition.

partContent :: ByteString
 

data Encoding Source

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

Constructors

None 
Base64 

Render a message

renderMail :: RandomGen g => g -> Mail -> (ByteString, g)Source

Render a Mail with a given RandomGen for producing boundaries.

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.

renderSendMail :: Mail -> IO ()Source

Render an email message and send via sendmail.

High-level Mail creation

simpleMailSource

Arguments

:: String

to

-> String

from

-> String

subject

-> Text

plain body

-> Text

HTML body

-> [(String, 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.