SMS usage
Register SmsModule
app.module.ts
import { Module } from '@nestjs/common';
import { SmsModule, SmsProvider } from 'nestjs-notification-module';
@Module({
imports: [
SmsModule.register({
isGlobal: true,
provider: SmsProvider.MUTLUCELL,
username: 'mutlucell-user',
password: 'mutlucell-pass',
originator: 'MYBRAND',
}),
],
})
export class AppModule {}
Send an SMS
sendAsync parameters
SmsService.sendAsync(args) accepts the following fields:
| Field | Type | Required | Notes |
|---|---|---|---|
countryCode | string | ✅ Yes | Country dialing code (e.g. "+90"). |
phoneNumber | string | ✅ Yes | Recipient phone number (without country code). |
message | string | ✅ Yes | SMS text content. |
sms.service.ts
import { Injectable } from '@nestjs/common';
import { SmsService } from 'nestjs-notification-module';
@Injectable()
export class SmsAppService {
constructor(private readonly sms: SmsService) {}
async sendOtp(phoneNumber: string) {
return this.sms.sendAsync({
countryCode: '+90',
phoneNumber,
message: 'Your code is 1234',
});
}
}