packages feed

SMTPClient 1.0.2 → 1.0.3

raw patch · 3 files changed

+126/−30 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Network.SMTP.Simple: NameAddr :: Maybe String -> String -> NameAddr
+ Network.SMTP.Simple: SimpleMessage :: [NameAddr] -> [NameAddr] -> String -> String -> SimpleMessage
+ Network.SMTP.Simple: body :: SimpleMessage -> String
+ Network.SMTP.Simple: data NameAddr :: *
+ Network.SMTP.Simple: data SimpleMessage
+ Network.SMTP.Simple: from :: SimpleMessage -> [NameAddr]
+ Network.SMTP.Simple: instance Show SimpleMessage
+ Network.SMTP.Simple: nameAddr_addr :: NameAddr -> String
+ Network.SMTP.Simple: nameAddr_name :: NameAddr -> Maybe String
+ Network.SMTP.Simple: sendRawMessages :: (String -> IO ()) -> SockAddr -> String -> [Message] -> IO ()
+ Network.SMTP.Simple: sendSimpleMessages :: (String -> IO ()) -> String -> String -> [SimpleMessage] -> IO ()
+ Network.SMTP.Simple: subject :: SimpleMessage -> String
+ Network.SMTP.Simple: to :: SimpleMessage -> [NameAddr]

Files

LICENSE view
@@ -1,27 +1,31 @@-/*- * Copyright (c) 2008, Stephen Blackheath- * All rights reserved.- *- * Redistribution and use in source and binary forms, with or without- * modification, are permitted provided that the following conditions are met:- *     * Redistributions of source code must retain the above copyright- *       notice, this list of conditions and the following disclaimer.- *     * Redistributions in binary form must reproduce the above copyright- *       notice, this list of conditions and the following disclaimer in the- *       documentation and/or other materials provided with the distribution.- *     * Neither the name of the <organization> nor the- *       names of its contributors may be used to endorse or promote products- *       derived from this software without specific prior written permission.- *- * THIS SOFTWARE IS PROVIDED BY STEPHEN BLACKHEATH ''AS IS'' AND ANY- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE- * DISCLAIMED. IN NO EVENT SHALL STEPHEN BLACKHEATH BE LIABLE FOR ANY- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.- */+Copyright (c) 2008 Stephen Blackheath <http://blacksapphire.com/antispam/>+Copyright (c) 2009 Matthew Elder +All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions+are met:++1. Redistributions of source code must retain the above copyright+   notice, this list of conditions and the following disclaimer.++2. Redistributions in binary form must reproduce the above copyright+   notice, this list of conditions and the following disclaimer in the+   documentation and/or other materials provided with the distribution.++3. Neither the name of the author nor the names of his contributors+   may be used to endorse or promote products derived from this software+   without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE+POSSIBILITY OF SUCH DAMAGE.
+ Network/SMTP/Simple.hs view
@@ -0,0 +1,92 @@+-----------------------------------------------------------------------------+-- |+-- Module      :  Network.SMTP.Simple+-- Copyright   :  2009 Matthew Elder+-- License     :  BSD3+--+-- Maintainer  :  Matthew Elder+-- Stability   :  provisional+-- Portability :  linux/windows+--+-- Mail is a simple library with which you can add email functionality to your+-- application. It assumes you have access to a smarthost which can relay all+-- your mail.+-- +-- As an example:+--+-- > import Network.SMTP.Simple+-- > import System.IO+-- >+-- > main :: IO ()+-- > main = do+-- >     sendSimpleMessages (hPutStrLn stderr) "10.2.23.11" "example.com" [message]+-- >     where message = SimpleMessage+-- >                         [NameAddr (Just "John Doe") "johnd@example.com"]+-- >                         [NameAddr (Just "Team") "team@exmaple.com"]+-- >                         "My test email using Network.SMTP.Simple"+-- >                         "Hi, this is a test email which uses SMTPClient."++module Network.SMTP.Simple+    ( NameAddr(..)+    , SimpleMessage(..)+    , sendRawMessages+    , sendSimpleMessages+    ) where++import Data.IORef (newIORef, readIORef)+import Network.Socket+    (SockAddr(..)+    , inet_addr+    )+import Network.SMTP.Client+import System.Time+    ( CalendarTime(..)+    , getClockTime+    , toCalendarTime+    )++data SimpleMessage+    = SimpleMessage+        { from :: [NameAddr] -- ^ The sender(s)+        , to :: [NameAddr]   -- ^ The recipient(s)+        , subject :: String  -- ^ The subject line+        , body :: String     -- ^ The body+        }+    deriving (Show)++toMessage :: CalendarTime -> SimpleMessage -> Message+toMessage ct sm =+    Message+        [From (from sm), To (to sm), Subject (subject sm), Date ct]+        (body sm)++-- | Simplest way to send mail.  Takes the smarthost ip, the HELO domain, and a list of SimpleMessage.+sendSimpleMessages :: (String -> IO ())  -- ^ Diagnostic log function+                   -> String          -- ^ IP address of the smarthost+                   -> String          -- ^ HELO domain (should be the same as your from-address-domain)+                   -> [SimpleMessage] -- ^ List of simple messages to send+                   -> IO ()+sendSimpleMessages log smartHostIp heloDomain simpleMessages = do+    nowCT <- toCalendarTime =<< getClockTime+    hostAddr <- inet_addr smartHostIp+    let smtpSockAddr = SockAddrInet 25 hostAddr+    sendRawMessages log smtpSockAddr heloDomain (map (toMessage nowCT) simpleMessages)++-- | Use this if you need more control than sendSimpleMessages gives you.+sendRawMessages :: (String -> IO ()) -- ^ Diagnostic log function+                -> SockAddr  -- ^ SockAddr for the smarthost+                -> String    -- ^ HELO domain (should be the same as your from-address-domain)+                -> [Message] -- ^ List of messages to send+                -> IO ()+sendRawMessages log smtpSockAddr heloDomain messages = do+    sentRef <- newIORef []+    sendSMTP' log (Just sentRef) heloDomain smtpSockAddr messages+    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 ->+            return ()+        Just status ->+            log $ "message failed: " ++ show status
SMTPClient.cabal view
@@ -1,10 +1,10 @@ name: SMTPClient-version: 1.0.2+version: 1.0.3 license: BSD3 license-file: LICENSE cabal-version: >= 1.6-copyright: (c) Stephen Blackheath-author: Stephen Blackheath+copyright: (c) Stephen Blackheath 2008, (c) Matthew Elder 2009+author: Stephen Blackheath, Matthew Elder, Jeremy Shaw maintainer: http://blacksapphire.com/antispam/ stability: stable synopsis: A simple SMTP client library@@ -19,7 +19,7 @@     type:     darcs     location: http://code.haskell.org/SMTPClient/ Library-    exposed-modules: Network.SMTP.Client, Network.SMTP.ClientSession+    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,                    containers, extensible-exceptions >= 0.1 && < 0.2