2.0.3 • Published 6 years ago

mail-bounce-snoop v2.0.3

Weekly downloads
25
License
BSD
Repository
github
Last release
6 years ago

This is a fork of

Node Bounce Snoop

github tag Build Status

Based on

This should help (email is messy) to detect if an email message is a bounce message

Usage

check if an email is a bounce

  const EmailSnoop = require('mail-bounce-snoop');

  let message = "<email as text with all header and parts>";

  //using Promise
  EmailSnoop.isBouncedEmail(message).then(isBounce => {
      if (isBounce) {
        console.log("This is a bounce message")
      }
  });
  
  //using callback
  EmailSnoop.isBouncedEmail(message.toString(), (isBounce) => {
      if (isBounce) {
        console.log("This is a bounce message")
      }
  });  
  
  //The message could be set with EmailSnoop.init(message), otherwise the snoop remembers the last used email

get bounce detail

  const EmailSnoop = require('mail-bounce-snoop');
  
  //using Promise
  EmailSnoop.getBouncedEmailDetail(message.toString()).then(result => {
    /*
    * e.g. result 
    * {
    *   "recipient":"receiver@mail.to",
    *   "status":"5.0.0",
    *   "action":"failed",
    *   "messageid":"<123456@abc.de>",
    *   "is":"bounce"
    * } 
    */
  });
  
  //using callback
  EmailSnoop.getBouncedEmailDetail(message.toString(), (result) => {
     //...
  });  

Example combination

  const EmailSnoop = require('mail-bounce-snoop');
  
  EmailSnoop.init(message);

  //using the email set via init
  EmailSnoop.isBounced((isBounce) => {
      if (!isBounce) {
        console.log("All fine");
        
        return;
      }
      
      //using the email set via init or previous function call
      EmailSnoop.getBouncedDetail().then(result => {
        console.log(`Email to ${result.recipient} failed with status ${result.status}`)
      });
  });
2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.1.0

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago