# mailgw-apis

> A JavaScript wrapper around the [mail.tm](https://docs.mail.gw/) api.

Latest version **2.0.1** (published 2023-03-28) · MIT license · 2 weekly downloads

## Install

```sh
npm install mailgw-apis
pnpm add mailgw-apis
yarn add mailgw-apis
bun add mailgw-apis
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2023-03-28 |
| First published | 2023-03-28 |
| Weekly downloads | 2 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 20.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Cemal |
| Maintainers | aaaroony |
| Keywords | mail, temp-mail |

## Links

- npm: https://www.npmjs.com/package/mailgw-apis
- Repository: https://github.com/aspx13/mailgw-apis
- Homepage: https://github.com/cemalgnlts/Mailjs#readme
- Issues: https://github.com/cemalgnlts/Mailjs/issues
- npm.io page: https://npm.io/package/mailgw-apis

## Dependencies (1)

- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.1

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2023-03-28

## README

# Mailjs

A JavaScript wrapper around the [mail.tm](https://docs.mail.tm/) api.

Probably one of the best API for creating temporary email accounts.

* Usage of our API for illegal activity is strictly prohibited.
* It is forbidden to sell programs or earn from it that exclusively uses our API (for example, creating a competing temp mail client and charging for it's usage).
* The general quota limit is 8 queries per second (QPS) per IP address.

# Installation

**npm**
```sh
npm install @cemalgnlts/mailjs
```

**yarn**
```sh
yarn add @cemalgnlts/mailjs
```

**CDN**
```
<script src="https://cdn.jsdelivr.net/gh/cemalgnlts/Mailjs@latest/mailjs.min.js"></script>
```

# Documentation

Returns a Promise object after the function is called. If the request is sent correctly, `status` returns true. If it returns incorrect, the `status` will be false and the `message` in the data is also added.

A successfull response example:

```json
{
  "status": true,
  "message": "ok",
  "data": ...
}
```

A failed response example:

```json
{
  "status": false,
  "message": "Invalid credentials.",
  "data": ...
}
```

To see all results, check out the API page: [https://api.mail.tm/](https://api.mail.tm/)

User needs to login to access JWT token. Registration does not return this information, log in after registration.


After the login process, the user's JWT token and ID are assigned to `mailjs.token` and `mailjs.id`

---

## Domain

### List Domains
```js
mailjs.getDomains()
  .then(console.log)
```

### Get Domain
```js
mailjs.getDomain("[domain id]")
  .then(console.log)
```

---

## Account

### Create Account
```js
mailjs.register("user@example.com", "password")
  .then(console.log)
```

### Login

`mailjs.token` and `mailjs.id` can be used to access the user token and id later.

```js
mailjs.login("user@example.com", "password")
  .then(console.log)
```

### Login With Token

If you use the JWT token stored in `mailjs.token` after login, it will allow you to login without username and password.

```js
mailjs.loginWithToken("eyJ0eXAiO...")
  .then(console.log)
```

### Get Account Data
```js
mailjs.me()
  .then(console.log)
```

### Delete Account
```js
mailjs.deleteMe()
  .then(console.log)
```

You can also use the id to access the user's information and delete their account.

```js
mailjs.deleteAccount("[account id]")
  .then(console.log)
```

```js
mailjs.getAccount("[account id]")
  .then(console.log)
```

---

## Message

### List messages
Gets all the Message resources of a given page.

```js
mailjs.getMessages()
  .then(console.log)
```


### Read a message
Retrieves a Message resource with a specific id (It has way more information than a message retrieved with GET /messages but it hasn't the "intro" member)

```js
mailjs.getMessage("[message id]")
  .then(console.log)
```

### Delete a message
```js
mailjs.deleteMessage("[message id]")
  .then(console.log)
```

### Make a message readed or unreaded.
`true` for make readed. `false` for make unreaded.

```js
mailjs.setMessageSeen("[message id]", true)
  .then(console.log)
```

## Source

### Get source
Gets a Message's Source resource (If you don't know what this is, you either don't really want to use it or you should [read this!](https://en.wikipedia.org/wiki/Email#Plain_text_and_HTML))

```js
mailjs.getSource("[message id]")
  .then(console.log)
```

## Helper Methods

### Create random account.

Creates and logs in an account with a random username and password.

```js
mailjs.createOneAccount()
  .then(console.log);
```

#### Response

```json
{
  "status": true,
  "data": {
    "username": "user@example.com",
    "password": "my-password"
  }
}
```

# Questions And Suggestions
If you have any questions or suggestions, please contact us via email [support@mail.tm](mailto:support@mail.tm) or [discord](https://discord.gg/mail).

---
_Source: https://npm.io/package/mailgw-apis · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
