1.0.5 • Published 9 months ago

promailer v1.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

promailer

Version License

A simple and fast Node.js package to send emails using Nodemailer.

Installation

npm install promailer

Usage

mailConfg

This function is used to configure the email transporter with the necessary settings.

const { mailConfg } = require('promailer');

const mailConfigData = {
  host: 'your-smtp-host',
  port: 'your-smtp-port',
  user: 'your-email@example.com',
  pass: 'your-email-password',
  tls: //true , false,
  secure://true, false
};

mailConfg(mailConfigData);

sendMail

This function is used to send an email using the configured transporter.

const { sendMail } = require('promailer');

// Sample usage
(async () => {
  try {
    const from = 'sender@example.com';
    const to = ['recipient1@example.com', 'recipient2@example.com'];
    const subject = 'Test Email';
    const template = '<h1>Hello, this is a test email!</h1>';

    const result = await sendMail(from, to, subject, template);
    console.log(result);
  } catch (error) {
    console.error(error.message);
  }
})();

Notes

  • The mailConfg function needs to be called once with valid configuration before using the sendMail function.
  • The sendMail function requires valid email addresses for both sender and recipients.
  • The package uses Nodemailer under the hood, and it supports TLS.

API

mailConfg(data)

This function takes a configuration object as input and sets up the email transporter.

  • data (Object) - An object containing mail configuration.
    • host (string) - The SMTP host (e.g., "smtp.gmail.com").
    • port (number) - The port number (e.g., 465).
    • user (string) - The username for authentication.
    • pass (string) - The password for authentication.
    • tls (boolean) - Whether to use TLS (optional, defaults to false).

sendMail(from, to, subject, template)

This function sends an email using the configured transporter.

  • from (string) - The sender's email address.
  • to (string[]) - An array of recipient email addresses.
  • subject (string) - The subject of the email.
  • template (string) - The HTML content of the email.

Returns a Promise that resolves to a success message with the email message ID if the email is sent successfully.


License

This project is licensed under the ISC License.


Please note that you can customize the package name, version, author, and description in the package.json file based on your preferences. If you have any further questions or need additional customization, feel free to ask!

Author : Kailash Mewada

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago