node-mailinator
node mailinator api.
Example
var mailinator = require('mailinator')({token: 'token-here'});
mailinator.getMessages('georgebush', function (err, messages) {
console.log(messages);
mailinator.readMessage(messages[0].id, function (err, res) {
console.log(res);
});
});
API
var mailinator = require('mailinator')(opts);
opts
An object of options:
opts.token
is a token string from mailinator. Required.opts.apiUrl
is the base url for the api. Defaults to"https://api.mailinator.com/api/"
.opts.to
is the local part of an email address that mail was sent to. E.g."obscure"
would aquire the mail sent to [email protected]
mailinator.getMessages(to, cb)
to
is the local part of an email address that mail was sent to. Ifnull
, the default isopts.to
.cb(err, messages)
err
is null or an Error object.messages
is the parsed response data. Examplemessages
object
// whatever@mailinator.com
mailinator.getMessages("whatever", function (err, data) {
console.dir(data); // => [{ id: '1420049469-71065803-whatever', ... }, ...]
})
mailinator.readMessage(msgId, cb)
msgId
is the id of the desired message. E.g."1420049469-71065803-whatever"
cb(err, message)
err
is null or an Error object.message
is the parsed response data. Examplemessage
object
// whatever@mailinator.com
mailinator.readMessage("1420049469-71065803-whatever", function (err, data) {
console.dir(data); // => { apiInboxFetchesLeft:697, apiEmailFetchesLeft: 10, ... }
})