Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
A library to parse e-mail messages both from a file and Milter(https://www.milter.org/).
- type RawMail = ByteString
- type RawFieldKey = ByteString
- type RawFieldValue = ByteString
- type RawBodyChunk = ByteString
- data Mail = Mail {
- mailHeader :: Header
- mailBody :: Body
- type Header = [Field]
- data Field = Field {}
- type CanonFieldKey = ByteString
- type FieldKey = ByteString
- type FieldValue = [ByteString]
- type Body = Seq ByteString
- canonicalizeKey :: FieldKey -> CanonFieldKey
- readMail :: FilePath -> IO Mail
- getMail :: RawMail -> Mail
- data XMail = XMail {
- xmailHeader :: Header
- xmailBody :: [RawBodyChunk]
- initialXMail :: XMail
- pushField :: RawFieldKey -> RawFieldValue -> XMail -> XMail
- pushBody :: RawBodyChunk -> XMail -> XMail
- finalizeMail :: XMail -> Mail
- lookupField :: FieldKey -> Header -> Maybe Field
- fieldsFrom :: FieldKey -> Header -> Header
- fieldsAfter :: FieldKey -> Header -> Header
- fieldsWith :: [CanonFieldKey] -> Header -> Header
- fieldValueFolded :: Field -> RawFieldValue
- fieldValueUnfolded :: Field -> RawFieldValue
- isEmpty :: Body -> Bool
- fromBody :: Body -> Builder
- fromBodyWith :: (ByteString -> ByteString) -> Body -> Builder
- removeTrailingEmptyLine :: Body -> Body
- parseTaggedValue :: RawFieldValue -> [(ByteString, ByteString)]
Documentation
Types for raw e-mail message
type RawMail = ByteString Source #
Type for raw e-mail message.
type RawFieldKey = ByteString Source #
Field key for raw e-mail message.
type RawFieldValue = ByteString Source #
Field value for raw e-mail message.
type RawBodyChunk = ByteString Source #
Body chunk for raw e-mail message.
Types for parsed e-mail message
Type for parsed e-mail message.
|
Field type for parsed e-mail message.
type CanonFieldKey = ByteString Source #
Type for canonicalized field key of parsed e-mail message.
type FieldKey = ByteString Source #
Type for field key of parsed e-mail message.
type FieldValue = [ByteString] Source #
Type for field value of parsed e-mail message.
type Body = Seq ByteString Source #
Type for body of parsed e-mail message.
canonicalizeKey :: FieldKey -> CanonFieldKey Source #
Canonicalizing FieldKey
for search.
Obtaining Mail
getMail :: RawMail -> Mail Source #
>>>
let out1 = finalizeMail $ pushBody "body" $ pushField "to" "val" $ pushField "from" "val" initialXMail
>>>
getMail "from: val\nto: val\n\nbody" == out1
True>>>
let out2 = finalizeMail $ pushBody "body" $ pushField "to" "val" $ pushField "from" "val\tval" initialXMail
>>>
getMail "from: val\tval\nto: val\n\nbody" == out2
True>>>
let out3 = finalizeMail $ pushBody "" $ pushField "to" "val" $ pushField "from" "val" initialXMail
>>>
getMail "from: val\nto: val\n" == out3
True
Obtaining Mail
incrementally.
Type for temporary data to parse e-mail message.
XMail | |
|
initialXMail :: XMail Source #
Initial value for XMail
.
pushField :: RawFieldKey -> RawFieldValue -> XMail -> XMail Source #
Storing field key and field value to the temporary data.
Functions to manipulate Header
fieldsWith :: [CanonFieldKey] -> Header -> Header Source #
Obtaining all fields with DKIM algorithm.
Functions to manipulate Field
fieldValueFolded :: Field -> RawFieldValue Source #
Obtaining folded (raw) field value.
fieldValueUnfolded :: Field -> RawFieldValue Source #
Obtaining unfolded (removing CRLF) field value.
Functions to manipulate Body
fromBodyWith :: (ByteString -> ByteString) -> Body -> Builder Source #
Obtaining body with a canonicalization function.
removeTrailingEmptyLine :: Body -> Body Source #
Removing trailing empty lines.
Special function for DomainKeys and DKIM
parseTaggedValue :: RawFieldValue -> [(ByteString, ByteString)] Source #
Parsing field value of tag=value.
>>>
parseTaggedValue " k = rsa ; p= MIGfMA0G; n=A 1024 bit key;"
[("k","rsa"),("p","MIGfMA0G"),("n","A1024bitkey")]>>>
parseTaggedValue " k = \nrsa ;\n p= MIGfMA0G;\n n=A 1024 bit key"
[("k","rsa"),("p","MIGfMA0G"),("n","A1024bitkey")]