email-router
A router for email addresses.
A lightweight router made for email addresses.
var email = ; email; ;// "Hello world"
Default email resolving includes:
- Ignoring
.
(i.e.f.o.o@example.com
tofoo@example.com
) - Ignoring
+tag
(i.e.foo+tag@example.com
tofoo@example.com
)
Installation
$ npm install --save email-router
API
router([options])
Creates a new email router, returning a route
function.
options.default
(String
): Route to use when none match.options.resolve
(Function
): Alternative resolver torouter.resolve
.
var foo = ;
router.resolve(address)
The default email resolver.
address
(String
): The email address to be resolved.
router;// "foo@example.com"
route(address, args)
Resolve address
and run the route handler(s) with args
bound using route.on
.
address
(String
): Email address being routed to that gets resolved.args
(Array
): Arguments to pass to the route handler(s).
var route = ;// ... bind routes with `route.on` ;
route.on(address, handler)
Create a handler to the resolved address
and executed with [route
][].
address
(String
): The resolved address to bind the handler to.handler
(Function
): Function to be triggered when routed to.
var route = ; route; ;// "Hello world"
License
MIT © Jamen Marzonie