-- |Showing a message will print it in roughly RFC-compliant
-- form. This form is sufficient for handing the message off to
--- sendmail.
+-- sendmail (or compatible).
instance Show Message where
show m =
concat [ if (length (headers m) == 0) then "" else (intercalate "\n" (headers m)) ++ "\n",
-- |Takes a message as an argument, and passes it to the system's
--- sendmail binary.
-sendmail :: Message -> IO (String, String, ExitCode)
-sendmail message = do
+-- sendmail (or compatible) binary.
+sendmail :: FilePath -> Message -> IO (String, String, ExitCode)
+sendmail sendmail_path message = do
let sendmail_args = ["-f",
(from message)]
(inh, outh, errh, ph) <-
- runInteractiveProcess "/usr/bin/sendmail" sendmail_args Nothing Nothing
+ runInteractiveProcess sendmail_path sendmail_args Nothing Nothing
outm <- newEmptyMVar
outs <- hGetContents outh