Package Exports
- @fastnloud/nest-mail
- @fastnloud/nest-mail/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@fastnloud/nest-mail) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Description
Mail module for Nest that uses Nodemailer to deliver messages.
Installation
$ npm i --save @fastnloud/nest-mailSetup
Import module:
import { MailModule } from '@fastnloud/nest-mail';
import { Module } from '@nestjs/common';
@Module({
imports: [MailModule],
})
export class AppModule {}A sample .env file looks something like this:
MAIL_DEFAULT_FROM_ADDRESS=john.doe@example.com
MAIL_DEFAULT_FROM_NAME=John Doe
MAIL_RECIPIENTS=
MAIL_URL=smtp://localhost:1025Usage
import { SmtpTransporter } from '@fastnloud/nest-mail';
import { Injectable } from '@nestjs/common';
import { SentMessageInfo } from 'nodemailer';
@Injectable()
export class MailService {
constructor(private readonly smtpTransporter: SmtpTransporter) {}
async send(): Promise<void> {
this.smtpTransporter.send(
{
to: 'jane.doe@example.com',
subject: `hello`,
text: 'world',
},
(error: Error | null, info: SentMessageInfo) => {
if (error) {
throw error;
}
console.log(info);
},
);
}
}License
nest-mail is MIT licensed.