summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2015-03-08 21:15:42 +0100
committertv <tv@shackspace.de>2015-03-08 21:15:42 +0100
commitd01c63788d09a887ffb114ee36d6787192a91e4d (patch)
treecd3ca06f0a148345b729222223f71fc956eacd61
parent331b129759beb0761573334d21f7165445855fa2 (diff)
ParseMail: parse multipart messages
-rw-r--r--ParseMail.hs12
1 files changed, 7 insertions, 5 deletions
diff --git a/ParseMail.hs b/ParseMail.hs
index 58b1a52..a1f91ab 100644
--- a/ParseMail.hs
+++ b/ParseMail.hs
@@ -34,16 +34,17 @@ readMail =
fromMIMEValue :: MIMEValue -> M.Mail
-fromMIMEValue val =
+fromMIMEValue val0 =
let m = foldr f (M.emptyMail $ M.Address Nothing "anonymous@localhost")
$ fromMIMEParams
- $ mime_val_headers val
- in m { M.mailParts = [[part]] }
+ $ mime_val_headers val0
+ in m { M.mailParts = [part val0] }
where
- part =
+ part val =
case mime_val_content val of
Single content ->
+ (:[]) $
M.Part
-- TODO actually check if we're utf-8 or ascii(?)
{ M.partType = "text/plain; charset=utf-8"
@@ -52,7 +53,8 @@ fromMIMEValue val =
, M.partHeaders = []
, M.partContent = LT.encodeUtf8 $ LT.fromStrict content
}
- _ -> error ("meh: " ++ show val)
+ Multi vals ->
+ concatMap part vals
--f :: H.Header -> M.Mail -> M.Mail
f (k, v) m = case k of