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

mail.tm-api

v3.0.1

Published

A powerful library to use the Mail.TM api and Mail.GW to receive emails

Downloads

161

Readme

mail.tm-api

XielQ - mail.tm-api stars - mail.tm-api forks - mail.tm-api

GitHub release License issues - mail.tm-api

⚡ A powerful library to use the Mail.TM and Mail.GW api to receive email

Installation

$ npm install mail.tm-api
# Or
$ yarn add mail.tm-api
# Or
$ pnpm add mail.tm-api
# Or
$ bun add mail.tm-api

Getting Started

  • Note: All functions are async/await

Account

Create Account

There is a bunch of way to create an account

const MailTM = require('mail.tm-api');

const account = await MailTM.createAccount();
// Or you can specify the mail address & password
const account = await MailTM.createAccount('ADDRESS', 'PASSWORD');
// Example: MailTM.createAccount('George', 'mySuperDuperPass')

You can create account with only domain

const domain = await MailTM.fetchDomains({ getRandomDomain: true });

const account = await MailTM.createAccount(domain, 'PASSWORD');
// Without password
const account = await MailTM.createAccount(domain);

Login Account

const MailTM = require('mail.tm-api');

const account = await MailTM.loginAccount('ADDRESS@DOMAIN', 'PASSWORD');

// Login using JWT

const account = await MailTM.loginAccount('TOKEN');

Note: If you have a token, you can use it instead of the address & password

Fetch Account Info

console.log(await account.fetch());
// { id: 'ID', address: 'ADDRESS@DOMAIN', ... }

Delete Account

console.log(await account.delete());
// true

Domains

Fetch domains

const MailTM = require('mail.tm-api');

console.log(await MailTM.fetchDomains());
// [{ id: 'DOMAIN_ID', domain: 'DOMAIN' }]

// Fetch a specific page

console.log(await MailTM.fetchDomains({ page: 2 }));
// [{ id: 'DOMAIN_ID', domain: 'DOMAIN' }]

// Get random domain
console.log(await MailTM.fetchDomains({ getRandomDomain: true }));

Configure Class

const MailTM = require('mail.tm-api');

MailTM.setConfig({
 // Props Here
});

Available props

  • mailService [Optional & 'mail.tm' | 'mail.gw'] = 'mail.tm': Change mail service
  • axiosOptions [Optional & Object] = {}: Axios request options

Emails

Get a cached email

console.log(account.emails.cache.get('MAIL_ID'));
// { id: 'MAIL_ID', accountId: 'ACCOUNT_ID', ... }

Note: account.emails.cache is a Map object, you can use all Map methods

Fetch a email

console.log(await account.emails.fetch('MAIL_ID'));
// { id: 'MAIL_ID', accountId: 'ACCOUNT_ID', ... }

// Or

console.log(await account.emails.cache.get('MAIL_ID').fetch());
// { id: 'MAIL_ID', accountId: 'ACCOUNT_ID', ... }

Fetch all emails

console.log(await account.emails.fetchAll());
// [{ id: 'MAIL_ID', accountId: 'ACCOUNT_ID', ... }, ...]

// Fetch a specific page

console.log(await account.emails.fetchAll(2));
// [{ id: 'MAIL_ID', accountId: 'ACCOUNT_ID', ... }, ...]

Listen for new emails

account.on('newMail', email => {
 console.log(email);
 // { id: 'MAIL_ID', accountId: 'ACCOUNT_ID', ... }
});

Delete a email

console.log(await account.emails.cache.get('MAIL_ID').delete());
// { id: 'MAIL_ID', accountId: 'ACCOUNT_ID', ..., isDeleted: true }

// Or

console.log(await (await account.emails.fetch('MAIL_ID')).delete());
// { id: 'MAIL_ID', accountId: 'ACCOUNT_ID', ..., isDeleted: true }

Download a email

console.log(await account.emails.cache.get('MAIL_ID').download('PATH.eml'));
// PATH.eml

// Or

console.log(await (await account.emails.fetch('MAIL_ID')).download('PATH.eml'));
// PATH.eml

License

Released under MIT by @XielQs.