# mailinator

## delete

Deletes sepcific email.

\*\* Example of the returned object:\*\*

```json
{
 "status": "ok"
}
```

**Parameters:**

| Name | Type     | Description |
| ---- | -------- | ----------- |
| `id` | `String` | Message ID. |

**Returns:**

`Object` - Status.

## fetch

Fetches specific email.

\*\* Example of the returned object:\*\*

```json
{
 "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@example.com",
     "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.

## getBody

Extracts first available email body.

**Parameters:**

| Name       | Type     | Description                                |
| ---------- | -------- | ------------------------------------------ |
| `emailObj` | `Object` | Email object returned by mailiniator.fetch |

**Returns:**

`String` - Email body.

## getSubject

Extracts email's subject.

**Parameters:**

| Name       | Type     | Description                                |
| ---------- | -------- | ------------------------------------------ |
| `emailObj` | `Object` | Email object returned by mailiniator.fetch |

**Returns:**

`String` - Email subject.

## init

Initializes mailinator module.

**Parameters:**

| Name            | Type     | Description                                           |
| --------------- | -------- | ----------------------------------------------------- |
| `token`         | `String` | API token.                                            |
| `privateDomain` | `String` | `optional` Specifies whether to use a private domain. |

## list

Fetches inbox messages or all saved messages.

\*\* Example of the returned object:\*\*

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

**Parameters:**

| Name    | Type     | Description                                                               |
| ------- | -------- | ------------------------------------------------------------------------- |
| `inbox` | `String` | `optional` Inbox name. If ommited saved messages will be fetched instead. |

**Returns:**

`Object` - List containing message details.
