module HSH.Helpers.Email where
import HSH
import HSH.Helpers.Utils
import Text.StringTemplate.Helpers
import System.IO.Error
newtype PureInput = PureInput { unpureinput :: String }
deriving (Read,Show)
mailxEmail emailBody subject "" = return . Left $ "no email recipient"
mailxEmail emailBody subject recipient = do
etR <- try $ run $ echo emailBody -|- mailxCommand
case etR of
Left e -> return $ Left $ show e
Right okmsg -> return $ Right okmsg
where mailxCommand = render1 [("subject",subject),("recipient",recipient)]
"mailx -s \"$subject$\" $recipient$"
t = do
etR <- mailxEmail "meh" "mah" "moo@gmail.com"
case etR of
Left e -> fail $ "error, e: " ++ e
Right () -> return "cool"