module Network.Smtp.Types
(
Mail,
MailT,
Extension(..),
AuthMethod(..),
MailConfig(..),
SmtpCommand(..),
SmtpException(..),
SmtpResponse(..)
)
where
import Control.ContStuff
import Control.Exception as Ex
import Data.ByteString (ByteString)
import Data.Enumerator
import Data.Set (Set)
import Data.Typeable
import Data.Vector (Vector)
import System.IO
import Text.Printf
data AuthMethod
= AuthMethod
deriving (Eq, Ord, Read, Show)
data Extension
= AuthExt (Set AuthMethod)
deriving (Eq, Ord, Read, Show)
type MailT r m = StateT r MailConfig (Iteratee SmtpResponse m)
type Mail r = MailT r IO
data MailConfig =
MailConfig {
mailExtensions :: Set Extension,
mailHandle :: Handle,
mailWriteTimeout :: Int
}
data SmtpCommand
= SmtpDataCmd
| SmtpHelloCmd ByteString
| SmtpMailFromCmd ByteString
| SmtpQuitCmd
| SmtpRcptToCmd ByteString
| SmtpResetCmd
| SmtpVerifyCmd ByteString
| SmtpWelcomeCmd
data SmtpException =
SmtpException {
smtpErrorMessage :: String,
smtpErrorCommand :: SmtpCommand,
smtpErrorCode :: Integer,
smtpErrorServerMessage :: String
}
deriving Typeable
instance Ex.Exception SmtpException
instance Show SmtpException where
show (SmtpException msg _ code srvMsg) =
printf "%s (%i): \"%s\"" msg code srvMsg
data SmtpResponse =
SmtpResponse {
smtpCode :: Integer,
smtpMessages :: Vector ByteString
}
deriving (Eq, Show)