smtp-mail 0.1.4.0 → 0.1.4.1
raw patch · 3 files changed
+116/−76 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Network.Mail.SMTP: AUTH :: AuthType -> UserName -> Password -> Command
- Network.Mail.SMTP: Address :: Maybe Text -> Text -> Address
- Network.Mail.SMTP: BadSequence :: Response
- Network.Mail.SMTP: CRAM_MD5 :: AuthType
- Network.Mail.SMTP: CannotVerify :: Response
- Network.Mail.SMTP: CommandNotImplemented :: Response
- Network.Mail.SMTP: DATA :: ByteString -> Command
- Network.Mail.SMTP: EHLO :: ByteString -> Command
- Network.Mail.SMTP: EXPN :: ByteString -> Command
- Network.Mail.SMTP: ErrorInProcessing :: Response
- Network.Mail.SMTP: ExceededStorage :: Response
- Network.Mail.SMTP: HELO :: ByteString -> Command
- Network.Mail.SMTP: HELP :: ByteString -> Command
- Network.Mail.SMTP: HelpMessage :: Response
- Network.Mail.SMTP: InsufficientSystemStorage :: Response
- Network.Mail.SMTP: LOGIN :: AuthType
- Network.Mail.SMTP: MAIL :: ByteString -> Command
- Network.Mail.SMTP: MailboxNotAllowed :: Response
- Network.Mail.SMTP: MailboxUnavailable :: Response
- Network.Mail.SMTP: MailboxUnavailableError :: Response
- Network.Mail.SMTP: NOOP :: Command
- Network.Mail.SMTP: Ok :: Response
- Network.Mail.SMTP: PLAIN :: AuthType
- Network.Mail.SMTP: ParameterError :: Response
- Network.Mail.SMTP: ParameterNotImplemented :: Response
- Network.Mail.SMTP: QUIT :: Command
- Network.Mail.SMTP: RCPT :: ByteString -> Command
- Network.Mail.SMTP: RSET :: Command
- Network.Mail.SMTP: ServiceClosing :: Response
- Network.Mail.SMTP: ServiceNotAvailable :: Response
- Network.Mail.SMTP: ServiceReady :: Response
- Network.Mail.SMTP: StartMailInput :: Response
- Network.Mail.SMTP: SyntaxError :: Response
- Network.Mail.SMTP: SystemStatus :: Response
- Network.Mail.SMTP: TransactionFailed :: Response
- Network.Mail.SMTP: UserNotLocal :: Response
- Network.Mail.SMTP: UserNotLocalError :: Response
- Network.Mail.SMTP: VRFY :: ByteString -> Command
- Network.Mail.SMTP: addressEmail :: Address -> Text
- Network.Mail.SMTP: addressName :: Address -> Maybe Text
- Network.Mail.SMTP: connectSMTPPort :: String -> PortNumber -> IO SMTPConnection
- Network.Mail.SMTP: data Address :: *
- Network.Mail.SMTP: data AuthType
- Network.Mail.SMTP: data Command
- Network.Mail.SMTP: data Response
- Network.Mail.SMTP: instance Eq Command
- Network.Mail.SMTP: instance Eq Response
- Network.Mail.SMTP: instance Show Command
- Network.Mail.SMTP: instance Show Response
- Network.Mail.SMTP: type Password = String
- Network.Mail.SMTP: type ReplyCode = Int
- Network.Mail.SMTP: type UserName = String
+ Network.Mail.SMTP: connectSMTP' :: HostName -> PortNumber -> IO SMTPConnection
+ Network.Mail.SMTP: instance Eq SMTPConnection
+ Network.Mail.SMTP: sendMail' :: HostName -> PortNumber -> Mail -> IO ()
+ Network.Mail.SMTP: sendMailWithLogin' :: HostName -> PortNumber -> UserName -> Password -> Mail -> IO ()
+ Network.Mail.SMTP.Types: AUTH :: AuthType -> UserName -> Password -> Command
+ Network.Mail.SMTP.Types: Address :: Maybe Text -> Text -> Address
+ Network.Mail.SMTP.Types: BadSequence :: Response
+ Network.Mail.SMTP.Types: CRAM_MD5 :: AuthType
+ Network.Mail.SMTP.Types: CannotVerify :: Response
+ Network.Mail.SMTP.Types: CommandNotImplemented :: Response
+ Network.Mail.SMTP.Types: DATA :: ByteString -> Command
+ Network.Mail.SMTP.Types: EHLO :: ByteString -> Command
+ Network.Mail.SMTP.Types: EXPN :: ByteString -> Command
+ Network.Mail.SMTP.Types: ErrorInProcessing :: Response
+ Network.Mail.SMTP.Types: ExceededStorage :: Response
+ Network.Mail.SMTP.Types: HELO :: ByteString -> Command
+ Network.Mail.SMTP.Types: HELP :: ByteString -> Command
+ Network.Mail.SMTP.Types: HelpMessage :: Response
+ Network.Mail.SMTP.Types: InsufficientSystemStorage :: Response
+ Network.Mail.SMTP.Types: LOGIN :: AuthType
+ Network.Mail.SMTP.Types: MAIL :: ByteString -> Command
+ Network.Mail.SMTP.Types: MailboxNotAllowed :: Response
+ Network.Mail.SMTP.Types: MailboxUnavailable :: Response
+ Network.Mail.SMTP.Types: MailboxUnavailableError :: Response
+ Network.Mail.SMTP.Types: NOOP :: Command
+ Network.Mail.SMTP.Types: Ok :: Response
+ Network.Mail.SMTP.Types: PLAIN :: AuthType
+ Network.Mail.SMTP.Types: ParameterError :: Response
+ Network.Mail.SMTP.Types: ParameterNotImplemented :: Response
+ Network.Mail.SMTP.Types: QUIT :: Command
+ Network.Mail.SMTP.Types: RCPT :: ByteString -> Command
+ Network.Mail.SMTP.Types: RSET :: Command
+ Network.Mail.SMTP.Types: ServiceClosing :: Response
+ Network.Mail.SMTP.Types: ServiceNotAvailable :: Response
+ Network.Mail.SMTP.Types: ServiceReady :: Response
+ Network.Mail.SMTP.Types: StartMailInput :: Response
+ Network.Mail.SMTP.Types: SyntaxError :: Response
+ Network.Mail.SMTP.Types: SystemStatus :: Response
+ Network.Mail.SMTP.Types: TransactionFailed :: Response
+ Network.Mail.SMTP.Types: UserNotLocal :: Response
+ Network.Mail.SMTP.Types: UserNotLocalError :: Response
+ Network.Mail.SMTP.Types: VRFY :: ByteString -> Command
+ Network.Mail.SMTP.Types: addressEmail :: Address -> Text
+ Network.Mail.SMTP.Types: addressName :: Address -> Maybe Text
+ Network.Mail.SMTP.Types: data Address :: *
+ Network.Mail.SMTP.Types: data AuthType
+ Network.Mail.SMTP.Types: data Command
+ Network.Mail.SMTP.Types: data Response
+ Network.Mail.SMTP.Types: instance Eq Command
+ Network.Mail.SMTP.Types: instance Eq Response
+ Network.Mail.SMTP.Types: instance Show Command
+ Network.Mail.SMTP.Types: instance Show Response
+ Network.Mail.SMTP.Types: type Password = String
+ Network.Mail.SMTP.Types: type ReplyCode = Int
+ Network.Mail.SMTP.Types: type UserName = String
- Network.Mail.SMTP: connectSMTP :: String -> IO SMTPConnection
+ Network.Mail.SMTP: connectSMTP :: HostName -> IO SMTPConnection
- Network.Mail.SMTP: sendMail :: String -> PortNumber -> Mail -> IO ()
+ Network.Mail.SMTP: sendMail :: HostName -> Mail -> IO ()
- Network.Mail.SMTP: sendMailWithLogin :: String -> PortNumber -> UserName -> Password -> Mail -> IO ()
+ Network.Mail.SMTP: sendMailWithLogin :: HostName -> UserName -> Password -> Mail -> IO ()
Files
- Network/Mail/SMTP.hs +40/−62
- Network/Mail/SMTP/Types.hs +58/−0
- smtp-mail.cabal +18/−14
Network/Mail/SMTP.hs view
@@ -2,30 +2,28 @@ module Network.Mail.SMTP ( -- * Main interface sendMail+ , sendMail' , sendMailWithLogin+ , sendMailWithLogin' , simpleMail , plainTextPart , htmlPart , filePart+ -- * Types- , Command(..)- , Response(..)- , ReplyCode+ , module Network.Mail.SMTP.Types , SMTPConnection- -- * Auth Types (reexports)- , UserName- , Password- , AuthType(..)- -- * Network.Mail.Mime types (reexports)- , Address (..)+ -- * Network.Mail.Mime's sendmail interface (reexports) , sendmail , sendmailCustom , renderSendMail , renderSendMailCustom+ -- * Establishing Connection- , connectSMTPPort , connectSMTP+ , connectSMTP'+ -- * Operation to a Connection , sendCommand , login@@ -34,6 +32,9 @@ ) where +import Network.Mail.SMTP.Auth+import Network.Mail.SMTP.Types+ import System.IO import System.FilePath (takeFileName) @@ -43,7 +44,6 @@ import Network import Network.BSD (getHostName)-import Network.Mail.SMTP.Auth import Network.Mail.Mime hiding (simpleMail) import Data.ByteString (ByteString)@@ -57,58 +57,21 @@ data SMTPConnection = SMTPC !Handle ![ByteString] -data Command = HELO ByteString- | EHLO ByteString- | MAIL ByteString- | RCPT ByteString- | DATA ByteString- | EXPN ByteString- | VRFY ByteString- | HELP ByteString- | AUTH AuthType UserName Password- | NOOP- | RSET- | QUIT- deriving (Show, Eq)--type ReplyCode = Int+instance Eq SMTPConnection where+ (==) (SMTPC a _) (SMTPC b _) = a == b -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)+-- | Connect to an SMTP server with the specified host and default port (25)+connectSMTP :: HostName -- ^ name of the server+ -> IO SMTPConnection+connectSMTP = flip connectSMTP' 25 -- | Connect to an SMTP server with the specified host and port-connectSMTPPort :: String -- ^ name of the server+connectSMTP' :: HostName -- ^ name of the server -> PortNumber -- ^ port number -> IO SMTPConnection-connectSMTPPort hostname port =+connectSMTP' hostname port = connectTo hostname (PortNumber port) >>= connectStream --- | Connect to an SMTP server with the specified host and default port (25)-connectSMTP :: String -- ^ name of the server- -> IO SMTPConnection-connectSMTP = flip connectSMTPPort 25- -- | Attemp to send a 'Command' to the SMTP server once tryOnce :: SMTPConnection -> Command -> ReplyCode -> IO ByteString tryOnce = tryCommand 1@@ -226,17 +189,32 @@ from = enc mailFrom to = map enc mailTo +-- | Connect to an SMTP server, send a 'Mail', then disconnect. Uses the default port (25).+sendMail :: HostName -> Mail -> IO ()+sendMail host mail = do+ con <- connectSMTP host+ renderAndSend con mail+ closeSMTP con+ -- | Connect to an SMTP server, send a 'Mail', then disconnect.-sendMail :: String -> PortNumber -> Mail -> IO ()-sendMail host port mail = do- con <- connectSMTPPort host port+sendMail' :: HostName -> PortNumber -> Mail -> IO ()+sendMail' host port mail = do+ con <- connectSMTP' host port renderAndSend con mail closeSMTP con +-- | Connect to an SMTP server, login, send a 'Mail', disconnect. Uses the default port (25).+sendMailWithLogin :: HostName -> UserName -> Password -> Mail -> IO ()+sendMailWithLogin host user pass mail = do+ con <- connectSMTP host+ _ <- sendCommand con (AUTH LOGIN user pass)+ renderAndSend con mail+ closeSMTP con+ -- | Connect to an SMTP server, login, send a 'Mail', disconnect.-sendMailWithLogin :: String -> PortNumber -> UserName -> Password -> Mail -> IO ()-sendMailWithLogin host port user pass mail = do- con <- connectSMTPPort host port+sendMailWithLogin' :: HostName -> PortNumber -> UserName -> Password -> Mail -> IO ()+sendMailWithLogin' host port user pass mail = do+ con <- connectSMTP' host port _ <- sendCommand con (AUTH LOGIN user pass) renderAndSend con mail closeSMTP con
+ Network/Mail/SMTP/Types.hs view
@@ -0,0 +1,58 @@+module Network.Mail.SMTP.Types (+ Command(..),+ ReplyCode,+ Response(..),++ -- * Auth types (re-exports)+ UserName,+ Password,+ AuthType(..),++ -- * "Network.Mail.Mime" types (re-exports)+ Address(..),+) where++import Network.Mail.SMTP.Auth++import Data.ByteString (ByteString)+import Network.Mail.Mime++data Command = HELO ByteString+ | EHLO ByteString+ | MAIL ByteString+ | RCPT ByteString+ | DATA ByteString+ | EXPN ByteString+ | VRFY ByteString+ | HELP ByteString+ | AUTH AuthType UserName Password+ | NOOP+ | RSET+ | QUIT+ deriving (Show, Eq)++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)
smtp-mail.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: smtp-mail-version: 0.1.4.0+version: 0.1.4.1 synopsis: Simple email sending via SMTP -- description: homepage: http://github.com/jhickner/smtp-mail@@ -20,18 +20,22 @@ location: git@github.com:jhickner/smtp-mail.git library- exposed-modules: Network.Mail.SMTP, Network.Mail.SMTP.Auth- -- other-modules: - build-depends: - base >= 4.5 && < 5,- network,- filepath,- mime-mail,- bytestring,- text,- cryptohash,- base16-bytestring,- base64-bytestring,- array+ exposed-modules:+ Network.Mail.SMTP+ Network.Mail.SMTP.Auth+ Network.Mail.SMTP.Types++ -- other-modules:++ build-depends: base >= 4.5 && < 5+ , array+ , base16-bytestring+ , base64-bytestring+ , bytestring+ , cryptohash+ , filepath+ , mime-mail+ , network+ , text ghc-options: -Wall -fwarn-tabs