summaryrefslogtreecommitdiff
path: root/src/Data/CSV/Table/Email.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Data/CSV/Table/Email.hs')
-rw-r--r--src/Data/CSV/Table/Email.hs25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/Data/CSV/Table/Email.hs b/src/Data/CSV/Table/Email.hs
index a121b3c..d70ac29 100644
--- a/src/Data/CSV/Table/Email.hs
+++ b/src/Data/CSV/Table/Email.hs
@@ -1,9 +1,9 @@
-module Data.CSV.Table.Email
- ( -- * Email representation
+module Data.CSV.Table.Email
+ ( -- * Email representation
Email (..)
-
+
-- * Send function
- , sendMail
+ , sendMail
) where
@@ -15,32 +15,29 @@ import Data.CSV.Table.Types
import Data.CSV.Table.Ops
-data Email = E { uid :: String
+data Email = E { uid :: String
, to :: String
, cc :: [String]
, sender :: String
, subject :: String
, text :: String
- , send :: Bool
+ , send :: Bool
} deriving (Show)
sendMail :: Table -> (RowInfo -> Email) -> IO ()
-sendMail t f = forM_ (mapRows f t) sendMail1
+sendMail t f = forM_ (mapRows f t) sendMail1
sendMail1 :: Email -> IO ()
sendMail1 e = do
let tmp = uid e
- let cmd = mailCmd e
+ let cmd = mailCmd e
writeFile tmp (text e)
- status <- if (send e) then show `fmap` system cmd else return "FAKESEND"
- putStrLn $ printf "[exec: %s] Status[%s]: %s %s" cmd (status) (uid e) (to e)
+ status <- if send e then show `fmap` system cmd else return "FAKESEND"
+ putStrLn $ printf "[exec: %s] Status[%s]: %s %s" cmd status (uid e) (to e)
mailCmd :: Email -> String
-mailCmd e =
+mailCmd e =
printf "mail -s \"%s\" -aFrom:%s %s %s < %s" (subject e) (sender e) (to e) (ccs $ cc e) (uid e)
where
ccs [] = ""
ccs xs = "-c " ++ intercalate "," xs
-
-
-