addressparser
v1.0.1
Published
Parse e-mail addresses
Downloads
2,064,596
Readme
addressparser
Parse e-mail address fields. Input can be a single address ("[email protected]"
), a formatted address ("Andris Reinman <[email protected]>"
), comma separated list of addresses ("[email protected], [email protected]"
), an address group ("disclosed-recipients:[email protected];"
) 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 "[email protected]; [email protected]"
is identical to "[email protected], [email protected]"
.
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 <[email protected]>');
console.log(addresses); // [{name: "andris", address:"[email protected]"}]
And when using groups
addressparser('Composers:"Bach, Sebastian" <[email protected]>, [email protected] (Mozzie);');
the result would be
[
{
name: "Composers",
group: [
{
address: "[email protected]",
name: "Bach, Sebastian"
},
{
address: "[email protected]",
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