SMTPClient 1.0.3 → 1.0.4
raw patch · 3 files changed
+45/−4 lines, 3 filesdep ~hsemailPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: hsemail
API changes (from Hackage documentation)
Files
- Network/SMTP/Client.hs +41/−0
- SMTPClient.cabal +2/−2
- example.hs +2/−2
Network/SMTP/Client.hs view
@@ -5,6 +5,47 @@ -- Data structures for representing SMTP status codes and email messages are -- re-exported here from /Text.ParserCombinators.Parsec.Rfc2821/ and -- /Text.ParserCombinators.Parsec.Rfc2822/ in the /hsemail/ package.+--+-- Here's a working example:+--+-- > import Network.SMTP.ClientSession+-- > import Network.SMTP.Client+-- > import Network.Socket+-- > import System.Time+-- > import System.IO+-- > import Data.Bits+-- > import Data.IORef+-- > +-- > myDomain = "example.com"+-- > smtpHost = "hubert" -- <-- Your SMTP server here+-- > +-- > -- This will send the author an email. I don't mind!+-- > main = do+-- > now <- getClockTime+-- > nowCT <- toCalendarTime now+-- > let message = Message [+-- > From [NameAddr (Just "Mr. Nobody") "nobody@example.com"],+-- > To [NameAddr (Just "Stephen Blackheath") "maxine@hip-to-be-square.com"],+-- > Subject "I'm using SMTPClient!",+-- > Date nowCT+-- > ]+-- > ("Dear Sir,\n"+++-- > "It has come to my attention that this is an email.\n"+++-- > "Yours sincerely,\n"+++-- > "Mr. Nobody\n")+-- > addrs <- getAddrInfo Nothing (Just smtpHost) Nothing+-- > let SockAddrInet _ hostAddr = addrAddress (addrs !! 0)+-- > sockAddr = SockAddrInet (fromIntegral 25) hostAddr+-- > putStrLn $ "connecting to "++show sockAddr+-- > sentRef <- newIORef []+-- > sendSMTP' (hPutStrLn stderr) (Just sentRef) myDomain+-- > sockAddr [message]+-- > statuses <- readIORef sentRef+-- > -- If no exception was caught, statuses is guaranteed to be+-- > -- the same length as the list of input messages, therefore head won't fail here.+-- > case head statuses of+-- > Nothing -> putStrLn "Message successfully sent"+-- > Just status -> putStrLn $ "Message send failed with status "++show status module Network.SMTP.Client ( sendSMTP,
SMTPClient.cabal view
@@ -1,5 +1,5 @@ name: SMTPClient-version: 1.0.3+version: 1.0.4 license: BSD3 license-file: LICENSE cabal-version: >= 1.6@@ -20,6 +20,6 @@ location: http://code.haskell.org/SMTPClient/ Library exposed-modules: Network.SMTP.Client, Network.SMTP.ClientSession, Network.SMTP.Simple- build-depends: base >= 3 && < 5, hsemail >= 1.6 && < 1.7, network, old-time, old-locale,+ build-depends: base >= 3 && < 5, hsemail == 1.*, network, old-time, old-locale, containers, extensible-exceptions >= 0.1 && < 0.2
example.hs view
@@ -7,7 +7,7 @@ import Data.IORef myDomain = "example.com"-smtpHost = "hubert.blacksapphire.com" -- <-- Your SMTP server here+smtpHost = "hubert" -- <-- Your SMTP server here -- This will send the author an email. I don't mind! main = do@@ -15,7 +15,7 @@ nowCT <- toCalendarTime now let message = Message [ From [NameAddr (Just "Mr. Nobody") "nobody@example.com"],- To [NameAddr (Just "Stephen Blackheath") "unprintable.distances.stephen@blacksapphire.com"],+ To [NameAddr (Just "Stephen Blackheath") "maxine@hip-to-be-square.com"], Subject "I'm using SMTPClient!", Date nowCT ]