npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cemalgnlts/mailjs

v3.0.1

Published

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

Downloads

12,941

Readme

Mailjs

A JavaScript wrapper around the 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

npm install @cemalgnlts/mailjs

yarn

yarn add @cemalgnlts/mailjs

CDN

<!-- It is only needed to listen to new messages. -->
<script src="https://cdn.jsdelivr.net/gh/cemalgnlts/[email protected]/eventsource.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@cemalgnlts/[email protected]/dist/mailjs.min.js"></script>

Quickstart

  • Nodejs (CommonJS)
const Mailjs = require("@cemalgnlts/mailjs");
  • Nodejs (ESM)
import Mailjs from "@cemalgnlts/mailjs";
  • Browser
<!-- You can exlude this if not listening to events. -->
<script src="https://cdn.jsdelivr.net/gh/cemalgnlts/[email protected]/eventsource.min.js"></script>
<!-- Mailjs library -->
<script src="https://cdn.jsdelivr.net/npm/@cemalgnlts/[email protected]/dist/mailjs.min.js"></script>

EventSourcePolyfill is only for listening to new incoming messages, see Events title for more information. Add EventSourcePolyfill before Mailjs.

const mailjs = new Mailjs();

mailjs.createOneAccount()
	.then(account => console.log(account.data));

For more reference visit /examples directory.

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. If there is no error, status always returns true.

A successfull response example:

{
  "status": true,
  "message": "ok",
  "data": {}
}

A failed response example:

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

Example use:

const acc = await mailjs.createOneAccount();

// If there is a error.
if(!acc.status) {
  // Show the cause of the error.
  console.error(acc.message);

  return;
}

// If successful, access the data.
console.log(acc.data);

To see all results, check out the API page: 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

mailjs.getDomains()
  .then(console.log);

Get Domain

mailjs.getDomain("[domain id]")
  .then(console.log);

Account

Create Account

mailjs.register("[email protected]", "password")
  .then(console.log);

Login

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

mailjs.login("[email protected]", "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.

mailjs.loginWithToken("eyJ0eXAiO...")
  .then(console.log);

Get Account Data

mailjs.me()
  .then(console.log);

Delete Account

mailjs.deleteMe()
  .then(console.log);

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

mailjs.deleteAccount("[account id]")
  .then(console.log);
mailjs.getAccount("[account id]")
  .then(console.log);

Message

List messages

Gets all the Message resources of a given page.

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)

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

Delete a message

mailjs.deleteMessage("[message id]")
  .then(console.log);

Make a message readed or unreaded.

true for make readed. false for make unreaded.

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

Events

Events are the Server Sent Events which are fired when message arrive, seen or delete. It also fires the error, open state.

on

Open an event listener to messages and error.

// Add it before other activities if you need it.
mailjs.on("open", msg => console.log("Event listening has begun."));

// When a new message arrives.
mailjs.on("arrive", msg => console.log(`Message id: ${msg.id} has arrived (${msg.intro}).`));

// When a message is marked as read.
mailjs.on("seen", msg => console.log(`Message id: ${msg.id} marked as seen.`));

// When a message is deleted.
mailjs.on("delete", msg => console.log(`Message id: ${msg.id} has been deleted.`));

// If an error occurs during listening.
mailjs.on("error", err => console.error("Something went wrong:", err));

off

Clears the events and safely closes event listener.

mailjs.off();

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!)

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

Helper Methods

Create random account.

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

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

Response

{
  "status": true,
  "message": "ok",
  "data": {
    "username": "[email protected]",
    "password": "my-password"
  }
}

Questions And Suggestions

If you have any questions or suggestions, please contact us via email [email protected] or discord.