New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mail.tm-api

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mail.tm-api

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

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

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

Getting Started

  • Note: All functions are async/await

Account

Create Account

There is a bunch of way to create an account

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

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

You can create account with only domain!

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

const account = await Mail.createAccount(domain, 'PASSWORD');
// Without password
const account = await Mail.createAccount(domain);
Login Account
const MailTM = require('mail.tm-api');

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

// Using with token

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 Mail = require('mail.tm-api');

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

// Fetch a specific page

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

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

Configure Class

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

MailTM.setConfig({
 // Props Here
});
Available props
  • disableListening [Optional & Boolean] = false: Disable listening for new emails
  • mailService [Optional & 'mail.tm' | 'mail.gw'] = 'mail.tm': Change mail service

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('newEmail', email => {
 console.log(email);
 // { id: 'MAIL_ID', accountId: 'ACCOUNT_ID', ... }
});

// Or

account.addListener('newEmail', 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

Licensed under the MIT License

Copyright (c) 2022 GamerboyTR

Keywords

FAQs

Package last updated on 28 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc