@10abdullahbutt/nestjs-mail-service
v1.0.0
Published
A NestJS module for handling all email-related operations.
Readme
@10abdullahbutt/nestjs-mail-service
A NestJS module for handling all email-related operations using Nodemailer.
Features
- Easy integration with NestJS projects
- Configurable transport (SMTP, etc.)
- Send emails with HTML/text
- Extensible for custom templates and providers
Installation
npm install @10abdullahbutt/nestjs-mail-serviceUsage
Import the Module
import { MailServiceModule } from '@10abdullahbutt/nestjs-mail-service';
@Module({
imports: [
MailServiceModule.forRoot({
transport: {
host: 'smtp.example.com',
port: 587,
auth: {
user: '[email protected]',
pass: 'password',
},
},
defaults: {
from: '[email protected]',
},
}),
],
})
export class AppModule {}Inject and Use the Service
import { MailService } from '@10abdullahbutt/nestjs-mail-service';
@Injectable()
export class UserService {
constructor(private readonly mailService: MailService) {}
async sendWelcomeEmail(to: string) {
await this.mailService.sendMail({
to,
subject: 'Welcome!',
text: 'Thank you for joining us.',
});
}
}Configuration
transport: Nodemailer transport optionsdefaults: Default mail options
Testing
npm run testDocker
Build and test inside Docker:
docker build -t nestjs-mail-service .Contributing
- Fork the repo
- Create your feature branch (
git checkout -b feature/fooBar) - Commit your changes (
git commit -am 'Add some fooBar') - Push to the branch (
git push origin feature/fooBar) - Create a new Pull Request
License
MIT
