HaskellNet 0.4.1 → 0.4.2
raw patch · 6 files changed
+45/−9 lines, 6 filesdep ~mime-mailPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: mime-mail
API changes (from Hackage documentation)
+ Network.HaskellNet.SMTP: sendMimeMail' :: String -> String -> String -> Text -> Text -> [(Text, Text, ByteString)] -> SMTPConnection -> IO ()
+ Network.HaskellNet.SMTP: sendMimeMail2 :: Mail -> SMTPConnection -> IO ()
Files
- CHANGELOG +4/−0
- HaskellNet.cabal +4/−3
- example/imap.hs +0/−0
- example/smtp.hs +6/−1
- src/Network/HaskellNet/IMAP.hs +2/−2
- src/Network/HaskellNet/SMTP.hs +29/−3
CHANGELOG view
@@ -1,3 +1,7 @@+0.4.1 -> 0.4.2+--------------++ - Add sendMimeMail' to send mime mails with in-memory attachments 0.4 -> 0.4.1 ------------
HaskellNet.cabal view
@@ -4,10 +4,11 @@ SMTP, and IMAP protocols. NOTE: this package will be split into smaller, protocol-specific packages in the future.-Version: 0.4.1+Version: 0.4.2 Copyright: (c) 2006 Jun Mukai Author: Jun Mukai-Maintainer: Jonathan Daugherty <cygnus@foobox.com>+Maintainer: Jonathan Daugherty <cygnus@foobox.com>,+ Leza Morais Lutonda <lemol-c@outlook.com> License: BSD3 License-file: LICENSE Category: Network@@ -55,5 +56,5 @@ cryptohash, base64-string, old-time,- mime-mail >= 0.4.0 && < 0.5,+ mime-mail >= 0.4.7 && < 0.5, text
example/imap.hs view
example/smtp.hs view
@@ -39,9 +39,14 @@ example4 = doSMTP server $ \conn -> sendMimeMail to from subject plainBody htmlBody [] conn --- | With attachments (modify the `attachments` binding)+-- | With file attachments (modify the `attachments` binding) example5 = doSMTP server $ \conn -> sendMimeMail to from subject plainBody htmlBody attachments conn++-- | With ByteString attachments+bsContent = B.pack [43,43,43,43]+example5_2 = doSMTP server $ \conn ->+ sendMimeMail' to from subject plainBody htmlBody [("application/zip", "filename.zip", bsContent)] conn -- | With authentication example6 = doSMTP server $ \conn -> do
src/Network/HaskellNet/IMAP.hs view
@@ -86,7 +86,7 @@ showQuery (NOTs qry) = "NOT " ++ show qry showQuery OLDs = "OLD" showQuery (ONs t) = "ON " ++ dateToStringIMAP t- showQuery (ORs q1 q2) = "OR " ++ show q1 ++ " " ++ show q2 + showQuery (ORs q1 q2) = "OR " ++ show q1 ++ " " ++ show q2 showQuery (SENTBEFOREs t) = "SENTBEFORE " ++ dateToStringIMAP t showQuery (SENTONs t) = "SENTON " ++ dateToStringIMAP t showQuery (SENTSINCEs t) = "SENTSINCE " ++ dateToStringIMAP t@@ -168,7 +168,7 @@ return (l' : ls) | isTagged l -> (l:) <$> getLs | otherwise -> return [l]- getLiteral l len = + getLiteral l len = do lit <- bsGet s len l2 <- strip <$> bsGetLine s let l' = BS.concat [l, crlfStr, lit, l2]
src/Network/HaskellNet/SMTP.hs view
@@ -56,7 +56,7 @@ -- * Operation to a Connection , sendCommand , closeSMTP- -- * Other Useful Operations + -- * Other Useful Operations , authenticate , sendMail , doSMTPPort@@ -64,6 +64,8 @@ , doSMTPStream , sendPlainTextMail , sendMimeMail+ , sendMimeMail'+ , sendMimeMail2 ) where @@ -75,7 +77,7 @@ import Control.Applicative ((<$>)) import Control.Exception-import Control.Monad (unless)+import Control.Monad (unless, when) import Data.Char (isDigit) @@ -308,7 +310,7 @@ myMail = simpleMail' (address to) (address from) (T.pack subject) body address = Address Nothing . T.pack --- | Send a mime mail.+-- | Send a mime mail. The attachments are included with the file path. sendMimeMail :: String -- ^ receiver -> String -- ^ sender -> String -- ^ subject@@ -324,6 +326,30 @@ sendMail from [to] (lazyToStrict renderedMail) con where address = Address Nothing . T.pack++-- | Send a mime mail. The attachments are included with in-memory 'ByteString'.+sendMimeMail' :: String -- ^ receiver+ -> String -- ^ sender+ -> String -- ^ subject+ -> LT.Text -- ^ plain text body+ -> LT.Text -- ^ html body+ -> [(T.Text, T.Text, B.ByteString)] -- ^ attachments: [(content_type, file_name, content)]+ -> SMTPConnection+ -> IO ()+sendMimeMail' to from subject plainBody htmlBody attachments con = do+ let myMail = simpleMailInMemory (address to) (address from) (T.pack subject)+ plainBody htmlBody attachments+ sendMimeMail2 myMail con+ where+ address = Address Nothing . T.pack++sendMimeMail2 :: Mail -> SMTPConnection -> IO ()+sendMimeMail2 mail con = do+ let (Address _ from) = mailFrom mail+ tos = map (T.unpack . addressEmail) $ mailTo mail+ when (null tos) $ fail "no receiver specified."+ renderedMail <- renderMail' mail+ sendMail (T.unpack from) tos (lazyToStrict renderedMail) con -- haskellNet uses strict bytestrings -- TODO: look at making haskellnet lazy