Changeset 37788 in project

07/25/19 00:21:12 (5 months ago)
1 edited


  • wiki/eggref/4/email-address

    r30681 r37788  
    3535This API will take its argument and try to parse a single mailbox or group. If nothing parses or there are characters left over after the parsing completes then the parse fails and #f is returned.
     37===== email-address-list
     39<procedure>(email-address-list string-port-or-lazy-sequence)</procedure>
     41This API will take its argument and try to parse a list of addresses separated by commas or whitespace.
     43It will parse as many addresses (mailboxes or groups) as it can. Any unparsable data will be returned in the 2nd value. If everything was parsable then the 2nd value will be #<lazy-null>.
     45This parser is much more lenient than a To: header parser because it allows the addresses to be delimited with whitespace and it does not require the whole input to be parsable in order to succeed.
     47==== Serialisers
     49===== name->string
     51<procedure>(name->string email-address)</procedure>
     53Returns the name part of the address
     55        > (use email-address)
     56        > (name->string (email-address "Andy Bennett <>"))
     57        "Andy Bennett"
     59===== local-part->string
     61<procedure>(local-part->string email-address)</procedure>
     63Returns the local part of the address as it appears in the original: the RFC allows MTAs to be case sensitive.
     65        > (use email-address)
     66        > (local-part->string (email-address "Andy Bennett <ANDYJPB@EXAMPLE.NET>"))
     67        "ANDYJPB"
     69===== local-part->string-ci
     71<procedure>(local-part->string-ci email-address)</procedure>
     73Returns a lower case version of the local part of the address. Use this if you know that the MTAs for the relevant domain are not case-sensitive. You can also use this to deduplicate addresses with mixed case local parts for domains with MTAs that are not case-sensitive.
     75        > (use email-address)
     76        > (local-part->string-ci (email-address "Andy Bennett <ANDYJPB@EXAMPLE.NET>"))
     77        "andyjpb"
     79===== domain-part->string
     81<procedure>(domain-part->string email-address)</procedure>
     83Returns a lower case version of the domain part of the address: DNS domain names are always case insensitive.
     85        > (use email-address)
     86        > (domain-part->string (email-address "Andy Bennett <ANDYJPB@EXAMPLE.NET>"))
     87        ""
     89===== addr-spec->string
     91<procedure>(addr-spec->string email-address)</procedure>
     93Returns the local@domain part of the email-address, suitable for use in an SMTP dialogue. The case of the local part will be the same in the original address. The domain part will be lower case.
     95        > (use email-address)
     96        > (addr-spec->string (email-address "Andy Bennett <ANDYJPB@EXAMPLE.NET>"))
     97        ""
    3799=== Examples
    43105        (email-address "Andy Bennett <>")
    44106        (email-address "Andy Bennett <@home,>")
    45         (email-address "Andy (the egg author) Bennett <>")
     107        (email-address "Andy (the egg author) Bennett <>") ; This one contains a comment that will not appear in the parsed output.
    46108        (email-address "\"Andy Bennett (Chicken)\" <>")
    54116=== License
    56   Copyright (C) 2014, Andy Bennett
     118  Copyright (C) 2014-2019, Andy Bennett
    57119  All rights reserved.
    83145=== Version History
    84 * Stand by for a stable release...
     146* 0.2, (2019/07/24) : I'm finally putting it into the CHICKEN coop!
     147* 0.1, (2014/04/11) : 0.1 was never available via `chicken-install` but if you installed it from git this is the version you would have got.
Note: See TracChangeset for help on using the changeset viewer.