Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

errormail

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

errormail

Error mail sender

  • 0.0.1
  • unpublished
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

ErrorMail

A Node.js module for sending error emails using the Nodemailer library.

Installation

npm i errormail

Usage

const ErrorMail = require('errormail');
const errorMail = new ErrorMail({
  transporter: {
    service: 'gmail',
    auth: {
      user: 'youremail@gmail.com',
      pass: 'yourpassword',
    }
  },
  receiver: {
    to: 'recipient@example.com',
  },
  showLogs: true,
});

//Usage Example1
const error = new Error('Something went wrong');
errorMail.sendError(error, 'optional-recipient@example.com', 'Optional Subject')
  .then(info => {
    console.log(`Error email sent: ${info.response}`);
  })
  .catch(err => {
    console.error('Error sending email:', err);
  });

//Usage Example2
fs.readFile('path/file/errors.txt', (err, chunk) => {
    if (err) {
        errorMail.sendError(
            err,
            'optional-recipient@example.com',
            'Optional Subject'
        );
    }
    ...
});

//Usage Example3
(async () => {
    try {
        await fs.promises.('path/file/errors.txt');
    } catch (err) {
        const sendedError = await errorMail.sendError(err, 'optional-recipient@example.com');
        console.log(sendedError);
        //handle err...
    }
})();

ErrorMail Constructor

The ErrorMail constructor takes an options object with the following properties:

const errorMail = new ErrorMail({
  transporter: {
    service: 'gmail', // String specifying the email service. Default is 'gmail'.
    auth: {
      user: 'sender@example.com', // String specifying the email address of the sender.
      pass: 'password' // String specifying the password for the email address of the sender.
    }
  },
  receiver: {
    to: 'recipient@example.com' // String specifying the email address of the recipient.
  },
  showLogs: false // Boolean specifying whether to show logs in the console. Default is false.
});

Options

When creating an instance of the ErrorMail class, you can provide the following options:

The ErrorMail constructor takes an options object with the following properties:

transporter: Object specifying the email service and authentication credentials. Required properties: service: String specifying the email service. Default is 'gmail'. auth: Object specifying the authentication credentials. Required properties: user: String specifying the email address of the sender. pass: String specifying the password for the email address of the sender. receiver: Object specifying the default recipient. Required properties: to: String specifying the email address of the recipient. showLogs: Boolean specifying whether to show logs in the console. Default is false. The sendError method is thenable and takes three optional parameters:

errorMail.sendError(error, to, subject);

error: Error object or string representing the error message. to: String specifying an optional recipient for the email. subject: String specifying an optional subject line for the email.

Example options object:
const options = {
  transporter: {
    service: 'gmail',
    auth: {
      user: 'youremail@gmail.com',
      pass: 'yourpassword'
    }
  },
  receiver: {
    to: 'recipient1@example.com, recipient2@example.com'
  },
  showLogs: true
};
You can then pass this options object as an argument when creating a new instance of the ErrorMail class:
const errorMail = new ErrorMail(options);

License This project is licensed under the MIT License - see the LICENSE file for details.

This README.md file includes information on how to install the module, as well as an example usage snippet that shows how to create an instance of the ErrorMail class and send an error email with optional recipient and subject parameters.

It also includes an Options section that describes the properties of the options object that can be passed to the ErrorMail constructor, as well as the optional parameters for the sendError method.

Finally, it includes a License section that describes the license for the module.

Keywords

FAQs

Package last updated on 20 Apr 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