addressparser
Parse e-mail addresses
Last updated 12 years ago by andris .
MIT · Original npm · Tarball · package.json
$ npm install addressparser 
SYNC missed versions from official npm registry.

addressparser

Parse e-mail address fields. Input can be a single address ("andris@kreata.ee"), a formatted address ("Andris Reinman <andris@kreata.ee>"), comma separated list of addresses ("andris@kreata.ee, andris.reinman@kreata.ee"), an address group ("disclosed-recipients:andris@kreata.ee;") or a mix of all the formats.

In addition to comma the semicolon is treated as the list delimiter as well (except when used in the group syntax), so a value "andris@kreata.ee; andris.reinman@kreata.ee" is identical to "andris@kreata.ee, andris.reinman@kreata.ee".

Installation

Install with npm

npm install addressparser

Usage

Include the module

var addressparser = require('addressparser');

Parse some address strings with addressparser(field)

var addresses = addressparser('andris <andris@tr.ee>');
console.log(addresses); // [{name: "andris", address:"andris@tr.ee"}]

And when using groups

addressparser('Composers:"Bach, Sebastian" <sebu@example.com>, mozart@example.com (Mozzie);');

the result would be

[
    {
        name: "Composers",
        group: [
            {
                address: "sebu@example.com",
                name: "Bach, Sebastian"
            },
            {
                address: "mozart@example.com",
                name: "Mozzie"
            }
        ]
    }
]

Be prepared though that groups might be nested.

Notes

This module does not decode any mime-word or punycode encoded strings, it is only a basic parser for parsing the base data, you need to decode the encoded parts later by yourself

License

MIT

Current Tags

  • 1.0.1                                ...           latest (9 years ago)

11 Versions

  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
  • 0.3.2                                ...           10 years ago
  • 0.3.1                                ...           10 years ago
  • 0.3.0                                ...           10 years ago
  • 0.2.1                                ...           11 years ago
  • 0.2.0                                ...           11 years ago
  • 0.1.3                                ...           12 years ago
  • 0.1.2                                ...           12 years ago
  • 0.1.1                                ...           12 years ago
  • 0.1.0                                ...           12 years ago
Maintainers (1)
Downloads
Total 1
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (1)
Dependents (3)

© 2010 - cnpmjs.org x YWFE | Home | YWFE