New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@nestjs-modules/mailer

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nestjs-modules/mailer

NestJS - a mailer module (@mailer)

  • 2.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
164K
decreased by-16.97%
Maintainers
1
Weekly downloads
 
Created

What is @nestjs-modules/mailer?

@nestjs-modules/mailer is a mailer module for NestJS applications. It provides a simple and flexible way to send emails using various transport methods such as SMTP, sendmail, and more. The module integrates seamlessly with NestJS, allowing developers to easily configure and use it within their applications.

What are @nestjs-modules/mailer's main functionalities?

Basic Email Sending

This feature allows you to send basic emails using SMTP configuration. The code sample demonstrates how to configure the mailer module and send a simple email.

const mailerConfig = {
  transport: {
    host: 'smtp.example.com',
    port: 587,
    auth: {
      user: 'username',
      pass: 'password'
    }
  }
};

@Module({
  imports: [MailerModule.forRoot(mailerConfig)],
  providers: [AppService],
})
export class AppModule {}

@Injectable()
export class AppService {
  constructor(private readonly mailerService: MailerService) {}

  async sendEmail() {
    await this.mailerService.sendMail({
      to: 'recipient@example.com',
      subject: 'Test Email',
      text: 'This is a test email',
    });
  }
}

Template-based Email Sending

This feature allows you to send emails using templates. The code sample demonstrates how to configure the mailer module with a template engine (Handlebars in this case) and send an email using a template.

const mailerConfig = {
  transport: {
    host: 'smtp.example.com',
    port: 587,
    auth: {
      user: 'username',
      pass: 'password'
    }
  },
  template: {
    dir: __dirname + '/templates',
    adapter: new HandlebarsAdapter(),
    options: {
      strict: true
    }
  }
};

@Module({
  imports: [MailerModule.forRoot(mailerConfig)],
  providers: [AppService],
})
export class AppModule {}

@Injectable()
export class AppService {
  constructor(private readonly mailerService: MailerService) {}

  async sendTemplateEmail() {
    await this.mailerService.sendMail({
      to: 'recipient@example.com',
      subject: 'Test Email',
      template: 'welcome',
      context: {
        name: 'John Doe'
      }
    });
  }
}

Email Attachments

This feature allows you to send emails with attachments. The code sample demonstrates how to configure the mailer module and send an email with an attachment.

const mailerConfig = {
  transport: {
    host: 'smtp.example.com',
    port: 587,
    auth: {
      user: 'username',
      pass: 'password'
    }
  }
};

@Module({
  imports: [MailerModule.forRoot(mailerConfig)],
  providers: [AppService],
})
export class AppModule {}

@Injectable()
export class AppService {
  constructor(private readonly mailerService: MailerService) {}

  async sendEmailWithAttachment() {
    await this.mailerService.sendMail({
      to: 'recipient@example.com',
      subject: 'Test Email with Attachment',
      text: 'Please find the attachment.',
      attachments: [
        {
          filename: 'test.txt',
          path: './test.txt'
        }
      ]
    });
  }
}

Other packages similar to @nestjs-modules/mailer

Keywords

FAQs

Package last updated on 30 Apr 2024

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