assumpta-core-0.1.0.1: Core functionality for an SMTP client

Safe HaskellSafe
LanguageHaskell2010

Network.Mail.Assumpta.Types

Description

Types for use with SMTP.

Notes

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

Documentation

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.

Constructors

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

Constructors

UnexpectedResponse

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.

Fields

ParseError String

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

Instances
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

Methods

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 "my-computer.org"
"HELO my-computer.org"
>>> toByteString $ MAIL "some-sender@my-org.com"
"MAIL FROM:<some-sender@my-org.com>"
>>> toByteString $ RCPT "delighted-recipient@dunder-mifflin.com"
"RCPT TO:<delighted-recipient@dunder-mifflin.com>"