doc.txt

Mail Parse Library

_Mail Parse_ Library
====================

Parse an email, or a stream of emails, into simple structures.

Data
====

An Email is a
> (make-email (listof (cons Symbol String)) (listof (listof String)))
> (define-struct email (headers messages))

Headers are an associative list of all the headers from the email, minus the
MIME headers.

Messages is a list of all the messages/attachments in the email. For normal
emails without attachments, this is a list of one element.

A message is a list of strings, each string representing one line from the
email.

Exceptions
==========

> exn:malformed-email

Raised when the email stream is overly confusing, e.g. missing "From " between
messages.

Functions
=========

> parse-archive : path -> (listof Email)

Parse each file using _parse-emails_ and produce a list of all the
parsed emails.

> parse-emails : [Input-port] -> (listof Email)

Use either the provided input port or _current-input-port_ as the stream of
emails. Parse each email using _parse-email_ and produce a list of all the
parsed emails.

> parse-email : [Input-port] -> Email

Use either the provided input port or _current-input-port_ as the stream of
a single email. Behaviour is undefined for a stream of multiple emails. Parse
the email into a structure, as defined above.

;; Is this file an email?
;; an-email-file? : path -> boolean
simple file extension checker for compatible filetypes.

;; get-email-header-val : key message -> value
;; return value associated with key in EMAIL HEADER 
returns the contents of a header field in a message

;;; tokeniser for email address fields  (to from cc) 
;; addresses-string-split : string -> (listof string?)
returns the email addresses only 
eg
'("name@domain.com" "n.n@anon.com")