NodeJS api for temporary emails
npm install tmpmail- 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);