- show m =
- concat [ if (length (headers m) == 0) then "" else (intercalate "\n" (headers m)) ++ "\n",
- "Subject: " ++ (subject m) ++ "\n",
- "From: " ++ (from m) ++ "\n",
- "To: " ++ (to m) ++ "\n",
- "\n",
- (body m) ]
-
-
-sendmail :: Message -> IO (String, String, ExitCode)
-sendmail message = do
+ show m =
+ concat [ formatted_headers,
+ "Subject: " ++ (subject m) ++ "\n",
+ "From: " ++ (from m) ++ "\n",
+ "To: " ++ (to m) ++ "\n",
+ "\n",
+ (body m) ]
+ where
+ formatted_headers =
+ if null (headers m)
+ then ""
+ else (intercalate "\n" (headers m)) ++ "\n"
+
+
+
+-- | Constructs a 'String' in RFC822 date format for the current
+-- date/time.
+rfc822_now :: IO String
+rfc822_now =
+ liftM (formatTime defaultTimeLocale rfc822DateFormat) getZonedTime
+
+
+
+
+-- |Takes a message as an argument, and passes it to the system's
+-- sendmail (or compatible) binary.
+sendmail :: FilePath -> Message -> IO (String, String, ExitCode)
+sendmail sendmail_path message = do