PLaneT parse-email Library

Parse a single email into a data structure representing the email.

Download

Since this is on PLaneT, to download this is as simple as running the following program.

(require (planet "parse-email.ss" ("mburns" "parse-email" 1 0)))

Documentation

Data

(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.

Functions

parse-emails
Contract
(() (input-port?) . opt-> . (listof email?))
Description
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
Contract
(() (input-port?) . opt-> . email?)
Description
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 an Email.

Exceptions

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

Dependencies

Contact

Mike Burns mike@mike-burns.com