Plasma GitLab Archive
Projects Blog Knowledge

Module Netaddress


module Netaddress: sig .. end
Parsing of mail addresses


Addresses indicate the senders and recipients of messages and correspond to either an individual mailbox or a group of mailboxes.
type local_part = string 
Usually the user name
type domain = string 
The domain of the mailbox
type addr_spec = local_part * domain option 
The pair local_part@domain as O'Caml type. The domain may be missing.
class mailbox : ?name:string -> string list -> addr_spec -> object .. end
A mailbox has a name, optionally a route (not used nowadays), and a formal address specification.
class group : string -> mailbox list -> object .. end
A group has a name, and consists of a number of mailboxes.
type t = [ `Group of group | `Mailbox of mailbox ] 
The union of mailbox and group
exception Parse_error of int * string
A parsing error. The int is the position in the parsed string
val parse : string -> t list
Parse a list of addresses in string representation, and return them as list of mailboxes or groups.

Examples:

  • parse "gerd@gerd-stolpmann.de" returns a single mailbox without name and route, and the given spec
  • parse "Gerd Stolpmann <gerd@gerd-stolpmann.de>" returns a single mailbox with name and spec, but without route
  • parse "abc@def.net, ghi" returns two mailboxes without name and route, and the two specs. The second address only has a local part, but no domain.
  • parse "g:abc@def.net, Me <me@domain.net>;, gs@npc.de" returns one group g with members abc@def.net and me@domain.net, and another mailbox gs@npc.de.
Old-style naming of mailboxes is not supported (e.g. "gerd@gerd-stolpmann.de (Gerd Stolpmann)" - the part in parentheses is simply ignored.
This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml