dropmail

1.0.5 • Public • Published

📧 dropmail nodejs

NPM version Downloads
Dependencies Known Vulnerabilities NPM quality

Temporal mail for node, that works for now :p

using dropmail.me

What's it about

DropMail api for NodeJS, for generating random temporal emails and reading the inbox, you can also forward emails to other emails :)

Internally it connects to wss://dropmail.me/websocket via websocket to get emails and listen for inwards emails

Installing

Npm:

$ npm install dropmail

Usage

NodeJS

What better explanation that the real deal, here is what it can do:

const DropMail = require('dropmail');
 
/** 
 * DropMail will create a temporal email for a random domain
 * or a specific one if you pass it in to the constructor
 */
let mail = new DropMail('10mail.org');
 
/**
 * Event for when mail is ready
 * you need to listen to this event or to 'address' event 
 * before you can make use of 'forward' and get the 'address' and 'hash'
 */
mail.on('ready', () => {
  /**
   * Forward all email to 'manoloedge96@gmail.com'
   * will send a confirmation email, can be in spam
   */
  mail.forward('manoloedge96@gmail.com')
    .then((res) => console.log(res))
    .catch((err) => console.log(err));
});
 
/**
 * Event for when generated address is received
 */
mail.on('address', (address) => {
  console.log('Got address: (' + address.address + ') with hash: (' + address.hash + ').');
});
 
/**
 * Event for when list of domains is received
 */
mail.on('domains', (domains) => {
  console.log('Got domains:', domains);
});
 
/**
 * Event for when an email is received
 */
mail.on('email', (email) => {
  console.log('Got email:', email);
});
 
process.on('SIGINT', () => {
  /**
   * Close the mail, no longer will it be able to receive messages
   */
  mail.close();
});
 

CLI

create

Create a temp email, and listen to inbox:


dropmail create [--domain <domain> --forward <email>]


domains

List all available domains


dropmail domains


Api

DropMail

This is the only thing you will use.

Signature:

interface DropMail extends EventEmitter {
  address: EmailAddress;
  constructor(domain?: string): DropMail;
  forward(to: string, locale?: string): Promise<any>;
  close(): void;
 
  // EventEmitter
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
  on(event: string | symbol, listener: (...args: any[]) => void): this;
  once(event: string | symbol, listener: (...args: any[]) => void): this;
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
  prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
  removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
  removeAllListeners(event?: string | symbol): this;
  setMaxListeners(n: number): this;
  getMaxListeners(): number;
  listeners(event: string | symbol): Function[];
  emit(event: string | symbol, ...args: any[]): boolean;
  eventNames(): Array<string | symbol>;
  listenerCount(type: string | symbol): number;
}

EmailAddress

Email address little thingy:

interface EmailAddress {
  address: string;
  hash: string;
  client: ws.WebSocket;
  constructor(address, hash, client): EmailAddress;
  json(): Object;
}

Package Sidebar

Install

npm i dropmail

Weekly Downloads

20

Version

1.0.5

License

ISC

Unpacked Size

9.97 kB

Total Files

4

Last publish

Collaborators

  • logginjs