Giter Site home page Giter Site logo

tmpmail's Introduction

Temporary Mail

NodeJS api for temporary emails

Install

npm install tmpmail

Usage

  • Create a temporary mail client
const TmpMail = require('tmpmail');
const client = TmpMail.Create();
  • Wait for client to initialize, and get your email address
client.on('ready', email => {
  console.log(email);

  // Or, alternatively:
  console.log(client.id);
});

Example output:

  • Fetch messages
client.fetch().then(messages => {
  console.log(messages);
});

Example output:

[
  {
    _id: '3e1ee21c5cce2436daa1e8206923695e',
    from: '[email protected]',
    to: '[email protected]',
    subject: 'Hello world!',
    date: 2021-02-09T11:46:42.000Z
  },
  {
    _id: '3e1ee21c5cce2436daa1e8206923b38a',
    from: '[email protected]',
    to: '[email protected]',
    subject: 'Hello world (for the second time)!',
    date: 2021-02-09T11:46:57.000Z
  }
]
  • Get email body
client.findMessage('3e1ee21c5cce2436daa1e8206923695e').then(msg => {
  console.log(msg);
});

Example output:

{
  _id: '3e1ee21c5cce2436daa1e8206923695e',
  from: '[email protected]',
  to: '[email protected]',
  subject: 'Hello world!',
  date: 2021-02-09T11:46:42.000Z,
  body: {
    text: 'Hello world from a stranger!',
    html: ''
  }
}
  • Create a message listener
// Check every 1000ms (1s) for new messages
client.startMessageListener(1000, msgs => {
  console.log('Got some new message(s):\n', msgs);
});

// Stop the listener after 10s
setTimeout(client.stopMessageListener, 10000);

License

Apache 2.0

tmpmail's People

Contributors

robincunningham2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

dka98

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.