|
@@ -6,13 +6,30 @@ import Data.ByteString (ByteString)
|
|
|
import qualified Data.ByteString as BS
|
|
|
import Data.SMTP.Response
|
|
|
|
|
|
-data ResponseCode = Unrecognized | InvalidHost | InvalidArguments {argumentError :: ByteString} |
|
|
|
- InvalidSetOfArguments |
|
|
|
- InvalidEmail {invalidEmailAddress :: ByteString} | Timeout | NotImplemented |
|
|
|
- BadSequence | MailboxUnavailable {unavailableMailbox :: ByteString} | TLSNotAvailable |
|
|
|
- TLSNoSecurity | AuthTypeNotSupported | RequiresTls | BadAuthCredentials |
|
|
|
- AuthRequired | Congestion | BadConnection | NoConversion | TempUndefined |
|
|
|
- InvalidCP deriving (Eq, Ord, Read, Show)
|
|
|
+import Text.StringConvert
|
|
|
+
|
|
|
+data ResponseCode =
|
|
|
+ Unrecognized -- ^ Generic unrecognized command error
|
|
|
+ | InvalidHost -- ^ Invalid host at HELO or EHLO argument
|
|
|
+ | InvalidArguments ByteString -- ^ Generic invalid argument error
|
|
|
+ | InvalidSetOfArguments -- ^ Invalid argument sequence error
|
|
|
+ | InvalidEmail ByteString -- ^ @InvalidEmail m@ means @m@ is not in the correct format for an email address
|
|
|
+ | Timeout -- ^ Timeout at server or client
|
|
|
+ | NotImplemented -- ^ Command not implemented
|
|
|
+ | BadSequence -- ^ Bad sequences of commands
|
|
|
+ | MailboxUnavailable String -- ^ @MailbxUnavailable m@ means m has the correct format, but does not exist
|
|
|
+ | TLSNotAvailable -- ^ Server can not do TLS
|
|
|
+ | TLSNoSecurity -- ^ The agreed TLS parameters are not good enough
|
|
|
+ | AuthTypeNotSupported -- ^ Server does not support the given authentication method
|
|
|
+ | RequiresTls -- ^ This feature is only avilable in TLS connections
|
|
|
+ | BadAuthCredentials -- ^ Bad authentication credentials
|
|
|
+ | AuthRequired -- ^ This feature is only available for authenticated users
|
|
|
+ | Congestion -- ^ Mailsystem congestion error
|
|
|
+ | BadConnection -- ^ There were connection problems
|
|
|
+ | NoConversion -- ^ This conversion of email encoding is not supported
|
|
|
+ | TempUndefined -- ^ Generic undefined temporary error
|
|
|
+ | InvalidCP -- ^ Capability has an invalid format
|
|
|
+ deriving (Eq, Ord, Read, Show)
|
|
|
|
|
|
errorMessage :: ResponseCode -> ByteString
|
|
|
errorMessage = renderResponse . toResponse
|
|
@@ -30,7 +47,7 @@ toResponse (InvalidEmail a) = Response PermanentError [] 501 (Just (5, 1, 3)) $
|
|
|
toResponse Timeout = Response TransientError [] 421 (Just (4, 2, 1)) "Connection timeout, closing transmission channel."
|
|
|
toResponse NotImplemented = Response PermanentError [] 502 (Just (5, 5, 1)) "Command not implemented"
|
|
|
toResponse BadSequence = Response PermanentError [] 503 (Just (5, 5, 1)) "Bad sequence of commands"
|
|
|
-toResponse (MailboxUnavailable a) = Response PermanentError [] 551 (Just (5, 5, 1)) $ BS.concat ["Nope, don't know ", a, "."]
|
|
|
+toResponse (MailboxUnavailable a) = Response PermanentError [] 551 (Just (5, 5, 1)) $ BS.concat ["Nope, don't know ", s a, "."]
|
|
|
toResponse TLSNotAvailable = Response TransientError [] 454 (Just (4, 7, 0)) "TLS not available due to temporary reason."
|
|
|
toResponse TLSNoSecurity = Response PermanentError [] 554 (Just (5, 7, 0)) "Get a non-broken TLS lib."
|
|
|
toResponse AuthTypeNotSupported = Response PermanentError [] 504 (Just (5, 5, 4)) "Autentication mechanism is not supported."
|