Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

email-address

  1. Outdated egg!
  2. email-address
    1. Description
    2. Author
    3. Repository
    4. Requirements
    5. API
      1. Parsers
        1. email-address
        2. email-address-list
      2. Serialisers
        1. name->string
        2. local-part->string
        3. local-part->string-ci
        4. domain-part->string
        5. addr-spec->string
    6. Examples
      1. RFC 822 Mailboxes
      2. RFC 822 Groups
    7. License
    8. Version History

Description

email-address provides eMail address handling procedures for reading eMail addresses in RFC 822 format as well as reading lists of addresses, such as commonly found in a 'To:' header.

Author

Andy Bennett

Repository

https://bitbucket.org/knodium/email-address

Requirements

API

Parsers

email-address
[procedure] (email-address string-port-or-lazy-sequence)

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

email-address-list
[procedure] (email-address-list string-port-or-lazy-sequence)

This API will take its argument and try to parse a list of addresses separated by commas or whitespace.

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

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

Serialisers

name->string
[procedure] (name->string email-address)

Returns the name part of the address

> (use email-address)
> (name->string (email-address "Andy Bennett <andyjpb@example.net>"))
"Andy Bennett"
local-part->string
[procedure] (local-part->string email-address)

Returns the local part of the address as it appears in the original: the RFC allows MTAs to be case sensitive.

> (use email-address)
> (local-part->string (email-address "Andy Bennett <ANDYJPB@EXAMPLE.NET>"))
"ANDYJPB"
local-part->string-ci
[procedure] (local-part->string-ci email-address)

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

> (use email-address)
> (local-part->string-ci (email-address "Andy Bennett <ANDYJPB@EXAMPLE.NET>"))
"andyjpb"
domain-part->string
[procedure] (domain-part->string email-address)

Returns a lower case version of the domain part of the address: DNS domain names are always case insensitive.

> (use email-address)
> (domain-part->string (email-address "Andy Bennett <ANDYJPB@EXAMPLE.NET>"))
"example.net"
addr-spec->string
[procedure] (addr-spec->string email-address)

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

> (use email-address)
> (addr-spec->string (email-address "Andy Bennett <ANDYJPB@EXAMPLE.NET>"))
"ANDYJPB@example.net"

Examples

RFC 822 Mailboxes

(use email-address)
(email-address "andyjpb@example.net")
(email-address "Andy Bennett <andyjpb@example.net>")
(email-address "Andy Bennett <@home,@computer:andyjpb@example.net>")
(email-address "Andy (the egg author) Bennett <andy.bennett@example.net>") ; This one contains a comment that will not appear in the parsed output.
(email-address "\"Andy Bennett (Chicken)\" <andyjpb@example.net>")

RFC 822 Groups

(use email-address)
(email-address "Chicken Peeps: andyjpb@example.net;")
(email-address "Chicken Peeps: Andy Bennett <andyjpb@example.net>, andy.bennett@example.net;")

License

 Copyright (C) 2014-2019, Andy Bennett
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
 
 Redistributions of source code must retain the above copyright notice, this
 list of conditions and the following disclaimer.
 Redistributions in binary form must reproduce the above copyright notice,
 this list of conditions and the following disclaimer in the documentation
 and/or other materials provided with the distribution.
 Neither the name of the author nor the names of its contributors may be
 used to endorse or promote products derived from this software without
 specific prior written permission.
 
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 POSSIBILITY OF SUCH DAMAGE.

Version History