module HSH.Helpers.Email where
import HSH
import Text.StringTemplate.Helpers

newtype PureInput = PureInput { unpureinput :: String }
  deriving (Read,Show)


{- |
  Send an email via mailx.

  For sysadmin steps required for this command to work with most of the work outsourced to gmail, see last three posts in thread

  http://groups.google.com/group/HAppS/browse_thread/thread/93317d4d7317040f/14cd89d98f1f4041

  This assumes a unixy environment, 
-}
mailxEmail emailBody subject recipient = runIO $ echo emailBody -|- mailxCommand
  where mailxCommand = render1 [("subject",subject),("recipient",recipient)]
                               "mailx -s \"$subject$\" $recipient$"