digi-sendzi is a simple yet powerful SMTP email-sending library built in JavaScript. It provides an easy-to-use interface for sending emails, supporting plain text, HTML content, and attachments.
Go to file
2024-09-30 17:12:10 +05:30
lib node library to send emails 2024-09-30 17:12:10 +05:30
.gitignore node library to send emails 2024-09-30 17:12:10 +05:30
index.js node library to send emails 2024-09-30 17:12:10 +05:30
package.json node library to send emails 2024-09-30 17:12:10 +05:30
README.md node library to send emails 2024-09-30 17:12:10 +05:30

digi-sendzi ✉️

digi-sendzi is a simple yet powerful SMTP email-sending library built in JavaScript. It provides an easy-to-use interface for sending emails, supporting plain text, HTML content, and attachments.

Features 🌟

  • Send emails using SMTP protocol: Reliable and secure email delivery.
  • Support for multipart emails: Easily send both text and HTML formats.
  • Attach files to emails: Include attachments for richer communication.
  • Basic authentication support: Use your username and password for authentication.
  • Simple error handling: Manage errors with ease.

Installation 🛠️

To install digi-sendzi, you can use npm:

npm install digi-sendzi

Usage 📧

Basic Example Heres a simple example of how to use digi-sendzi to send an email:

import { createTransport } from 'digi-sendzi';

const transporter = createTransport({
    host: 'smtp.example.com',
    port: 587,
    auth: {
        user: 'your-email@example.com',
        pass: 'your-email-password'
    }
});

const mailOptions = {
    from: 'your-email@example.com',
    to: 'recipient@example.com',
    subject: 'Hello from digi-sendzi! 🌍',
    text: 'This is a plain text message.',
    html: '<strong>This is a bold HTML message.</strong>',
    attachments: [
        {
            filename: 'example.txt',
            content: 'Hello, this is the content of the file!',
            contentType: 'text/plain'
        }
    ]
};

transporter.sendMail(mailOptions)
    .then(() => {
        console.log('Email sent successfully! 🎉');
    })
    .catch((error) => {
        console.error('Error sending email:', error.message);
    });

API Reference 📚

createTransport(options)

Creates a new Transporter instance.

options: An object containing the following properties:

  • host (string): The SMTP server host.
  • port (number, optional): The port to connect to (default is 25).
  • auth (object, optional): An object containing user and pass for authentication.

Transporter.sendMail(mailOptions)

Sends an email with the specified options.

mailOptions: An object containing the following properties:

  • from (string): Sender's email address (required).
  • to (string): Recipient's email address (required).
  • subject (string): Email subject (required).
  • text (string): Plain text body of the email (required).
  • html (string, optional): HTML body of the email.
  • attachments (array, optional): An array of attachment objects with filename, content, and contentType.

Error Handling ⚠️

digi-sendzi provides basic error handling. If any required fields are missing or an error occurs during the SMTP connection or email sending, an error will be thrown. You can catch these errors using a .catch() block when sending an email.

Development 💻

To run tests, ensure you have Jest installed as a dev dependency, and run:

npm test

License 📝

This project is licensed under the ISC License.

Author ✍️

DigiMantra