npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

techxnix-mail

v1.0.1

Published

Techxnix Mail Library for NestJS applications - A powerful and easy-to-use mail module using SendGrid

Downloads

9

Readme

Techxnix Mail

A powerful and easy-to-use NestJS mail module for sending emails using SendGrid.

Features

  • 📧 Send plain text and HTML emails
  • 📝 Support for SendGrid templates
  • 📎 File attachments support
  • 🔄 Dynamic template data
  • 🎨 Custom sender information
  • 📝 Comprehensive logging
  • 🌐 Global module configuration
  • 🔒 Type-safe interfaces

Installation

npm install techxnix-mail

Quick Start

  1. Import TechxnixMailModule in your app.module.ts:
import { TechxnixMailModule } from 'techxnix-mail';

@Module({
  imports: [
    TechxnixMailModule.forRoot({
      sendGridApiKey: process.env.SENDGRID_API_KEY,
      defaultFromEmail: process.env.DEFAULT_FROM_EMAIL, // optional
      defaultFromName: process.env.DEFAULT_FROM_NAME,   // optional
    }),
  ],
})
export class AppModule {}
  1. Inject and use MailService in your services:
import { MailService } from 'techxnix-mail';

@Injectable()
export class YourService {
  constructor(private readonly mailService: MailService) {}

  // Send a simple email
  async sendEmail() {
    await this.mailService.send({
      to: '[email protected]',
      subject: 'Welcome!',
      text: 'Welcome to our platform!',
      html: '<h1>Welcome to our platform!</h1>',
    });
  }

  // Send using a SendGrid template
  async sendTemplateEmail() {
    await this.mailService.sendTemplate(
      '[email protected]',
      'd-template-id',
      { name: 'John' },
      { subject: 'Welcome!' }
    );
  }
}

Configuration

Environment Variables

SENDGRID_API_KEY=your_sendgrid_api_key
[email protected]
DEFAULT_FROM_NAME=Your App Name

Configuration Options

| Option | Type | Required | Description | |--------|------|----------|-------------| | sendGridApiKey | string | Yes | Your SendGrid API key | | defaultFromEmail | string | No | Default sender email address | | defaultFromName | string | No | Default sender name |

API Reference

MailService

send(options: IMailOptions): Promise

Send an email with the following options:

interface IMailOptions {
  to: string | string[];
  subject: string;
  text?: string;
  html?: string;
  from?: {
    email?: string;
    name?: string;
  };
  templateId?: string;
  dynamicTemplateData?: Record<string, any>;
  attachments?: Array<{
    content: string;
    filename: string;
    type?: string;
    disposition?: string;
    contentId?: string;
  }>;
}

sendTemplate(to: string | string[], templateId: string, dynamicTemplateData: Record<string, any>, options?: Partial): Promise

Send an email using a SendGrid template.

Logging

The module includes comprehensive logging:

  • Initialization logs
  • Pre-send attempt logs
  • Success/failure status
  • Detailed error information
  • Template usage logs

Example log output:

[MailService] SendGrid API Key configured
[MailService] Attempting to send email to: [email protected]
[MailService] Email sent successfully to [email protected]. Status: 202

Error Handling

The module provides detailed error information in logs:

  • SendGrid API errors
  • Configuration issues
  • Template rendering errors
  • Network problems

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

MIT

Support

For support, email [email protected] or create an issue in our GitHub repository.