assumpta-core- Core functionality for an SMTP client

Safe HaskellSafe



Types for use with SMTP.


Some notes on the underlying bits of the SMTP protocol they model (see RFC 5321 for more details):

  • The protocol consists of commands and replies.
  • Replies can be single-line or multiline. Single lines start with <reply-code> <SP>; for multiple lines, every line except the last starts with <reply-code> '-', and the last is a single line.

    The <SP> or '-' can be followed by optional text. Our ReplyLine and Reply store the code and the optional text (or an empty string if there was none), but not the <SP> or '-' separator.

  • A reply is a list of one or more of these reply lines; but we just represent it as a list; it's an invariant that such a list should never be empty (and the parser promises never to return an empty list).


type ReplyCode = Int Source #

Reply code from a server

type Reply = [ReplyLine] Source #

Response from a serve

data ReplyLine Source #

One line of a reply from a server, consisting of a ReplyCode and US-ASCII message.


Show ReplyLine Source # 
Instance details

Defined in Network.Mail.Assumpta.Types

data SmtpCommand Source #

SMTP commands. This type does not include the 'AUTH' command, which has a flexible form.

data SmtpError Source #

Errors that can occur during SMTP operations.

These don't include connectivity and other IO errors which might occur in the underlying transport mechanism; those should be handled elsewhere (if necessary).

The possible errors are that either (a) we couldn't parse the server's response at all, or (b) we could, but it wasn't what we expected.



We received a response contrary to what we expected. The first field is a description of what we expected, the second of what we got.


ParseError String

We couldn't parse the server's response; the parser gave the error message contained in the ParseError.

Show SmtpError Source # 
Instance details

Defined in Network.Mail.Assumpta.Types

Monad m => MonadError SmtpError (SmtpT conn m) # 
Instance details

Defined in Network.Mail.Assumpta.Trans.Smtp


throwError :: SmtpError -> SmtpT conn m a #

catchError :: SmtpT conn m a -> (SmtpError -> SmtpT conn m a) -> SmtpT conn m a #

toByteString :: SmtpCommand -> ByteString Source #

Dump an SMTP command to a bytestring, suitable for transmission to a server. No CRLF is appended.

For commands like 'MAIL FROM:<somesender@somedomain>': this adds in the 'FROM:<' etc

>>> :set -XOverloadedStrings
>>> toByteString $ HELO ""
>>> toByteString $ MAIL ""
>>> toByteString $ RCPT ""
"RCPT TO:<>"