mime-mail-0.4.6: Compose MIME email messages.

Safe HaskellNone

Network.Mail.Mime

Contents

Synopsis

Datatypes

newtype Boundary Source

MIME boundary between parts of a message.

Constructors

Boundary 

Fields

unBoundary :: Text
 

Instances

data Mail Source

An entire mail message.

Constructors

Mail 

Fields

mailFrom :: Address
 
mailTo :: [Address]
 
mailCc :: [Address]
 
mailBcc :: [Address]
 
mailHeaders :: Headers

Other headers, excluding from, to, cc and bcc.

mailParts :: [Alternatives]

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.

Instances

Show Mail 

emptyMail :: Address -> MailSource

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

data Address Source

Constructors

Address 

Fields

addressName :: Maybe Text
 
addressEmail :: Text
 

Instances

Show Address 

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 :: Text

content type

partEncoding :: Encoding
 
partFilename :: Maybe Text

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

partHeaders :: Headers
 
partContent :: ByteString
 

Instances

Show Part 

data Encoding Source

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

Instances

Show Encoding 

type Headers = [(ByteString, Text)]Source

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 default sendmail executable with default options.

sendmailCustomSource

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 ()Source

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

renderSendMailCustomSource

Arguments

:: FilePath

sendmail executable path

-> [String]

sendmail command-line options

-> Mail

mail to render and send

-> IO () 

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

High-level Mail creation

simpleMailSource

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.

simpleMail'Source

Arguments

:: Address

to

-> Address

from

-> Text

subject

-> Text

body

-> Mail 

A simple interface for generating an email with only plain-text body.

Utilities

addAttachment :: Text -> FilePath -> Mail -> IO MailSource

Add an attachment from a file and construct a Part.

addAttachments :: [(Text, FilePath)] -> Mail -> IO MailSource

htmlPart :: Text -> PartSource

Construct a UTF-8-encoded html Part.

plainPart :: Text -> PartSource

Construct a UTF-8-encoded plain-text Part.

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.