mailinator

Provides methods for working with Mailinator service - www.mailinator.com

Methods

init(token, privateDomain)

Initializes mailinator module.
Parameters:
Name Type Description
token String API token.
privateDomain String optionalSpecifies whether to use a private domain.

list(inbox)→ {Object}

Fetches inbox messages or all saved messages.


Example of the returned object

{
  "messages": [
    {
      "fromfull": "noreply@example.com",
      "subject": "Subject",
      "from": "Test Tester",
      "origfrom": "Test Tester <noreply>",
      "to": "inbox-name",
      "id": "RANDOMLY GENERATED ID",
      "time": 1491200030000,
      "seconds_ago": 234
    },
  ]
}

Parameters:
Name Type Description
inbox String optionalInbox name. If ommited saved messages will be fetched instead.
Returns:
Object - List containing message details.

fetch(id)→ {Object}

Fetches specific email.


Example of the returned object

{
  "data":
    {
      "fromfull":"noreply@example.com",
      "headers": { ... email headers ... },
      "subject":"test subject",
      "requestId":"REQUEST ID",
      "parts": [
        {
          "headers":{ "content-type":"text/plain; charset=utf-8" },
          "body":"EMAIL BODY (TEXT)"
        },
        {
          "headers":{ "content-type":"text/html; charset=utf-8" },
          "body":"EMAIL BODY (HTML)"
        }
      ],
      "from":"Test Tester",
      "origfrom":"Test Tester <noreply>",
      "to":"cb-test-2",
      "id":"RANDOMLY GENERATED ID",
      "time":1491200030000,
      "seconds_ago":1174
   },
  "apiEmailFetchesLeft":1999
}

Parameters:
Name Type Description
id String Message ID.
Returns:
Object - Email details. E.g.

getSubject(emailObj)→ {String}

Extracts email's subject.
Parameters:
Name Type Description
emailObj Object Email object returned by mailiniator.fetch
Returns:
String - Email subject.

getBody(emailObj)→ {String}

Extracts first available email body.
Parameters:
Name Type Description
emailObj Object Email object returned by mailiniator.fetch
Returns:
String - Email body.

delete(id)→ {Object}

Deletes sepcific email.


Example of the returned object

{
  "status": "ok"
}
Parameters:
Name Type Description
id String Message ID.
Returns:
Object - Status.