module Network.Mail.SMTP.Types (
AuthType(..)
, UserName
, Password
, Command(..)
, toByteString
, ReplyCode
, Response(..)
, Address(..)
) where
import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as B
import Network.Mail.Mime
type UserName = String
type Password = String
data AuthType
= LOGIN
deriving (Show)
data Command
= HELO ByteString
| EHLO ByteString
| MAIL ByteString
| RCPT ByteString
| DATA
| EXPN ByteString
| VRFY ByteString
| HELP ByteString
| NOOP
| RSET
| QUIT
| STARTTLS
deriving (Show, Eq)
toByteString :: Command -> B.ByteString
toByteString command = case command of
HELO bs -> B.intercalate space [(B.pack "HELO"), bs]
EHLO bs -> B.intercalate space [(B.pack "EHLO"), bs]
MAIL bs -> B.append (B.pack "MAIL FROM:<") (B.append bs ">")
RCPT bs -> B.append (B.pack "RCPT TO:<") (B.append bs ">")
EXPN bs -> B.intercalate space [(B.pack "EXPN"), bs]
VRFY bs -> B.intercalate space [(B.pack "VRFY"), bs]
HELP bs -> B.intercalate space [(B.pack "HELP"), bs]
DATA -> B.pack "DATA"
NOOP -> B.pack "NOOP"
RSET -> B.pack "RSET"
QUIT -> B.pack "QUIT"
STARTTLS -> B.pack "STARTTLS"
where
space = B.pack " "
type ReplyCode = Int
data Response
= Ok
| SystemStatus
| HelpMessage
| ServiceReady
| ServiceClosing
| UserNotLocal
| CannotVerify
| StartMailInput
| ServiceNotAvailable
| MailboxUnavailable
| ErrorInProcessing
| InsufficientSystemStorage
| SyntaxError
| ParameterError
| CommandNotImplemented
| BadSequence
| ParameterNotImplemented
| MailboxUnavailableError
| UserNotLocalError
| ExceededStorage
| MailboxNotAllowed
| TransactionFailed
deriving (Show, Eq)