diff --git a/apps/auth/src/main.ts b/apps/auth/src/main.ts index 7d68bcc..2303cb7 100644 --- a/apps/auth/src/main.ts +++ b/apps/auth/src/main.ts @@ -27,6 +27,6 @@ async function bootstrap() { app.useGlobalPipes(new ValidationPipe()); - await app.listen(6001); + await app.listen(7001); } bootstrap(); diff --git a/apps/backend/src/main.ts b/apps/backend/src/main.ts index c062492..394a30f 100644 --- a/apps/backend/src/main.ts +++ b/apps/backend/src/main.ts @@ -21,6 +21,6 @@ async function bootstrap() { }), ); app.useGlobalPipes(new ValidationPipe()); - await app.listen(6000); + await app.listen(7000); } bootstrap(); diff --git a/libs/common/src/config/email.config.ts b/libs/common/src/config/email.config.ts index 4050433..199d084 100644 --- a/libs/common/src/config/email.config.ts +++ b/libs/common/src/config/email.config.ts @@ -3,7 +3,10 @@ import { registerAs } from '@nestjs/config'; export default registerAs( 'email-config', (): Record => ({ - EMAIL_ID: process.env.EMAIL_USER, - PASSWORD: process.env.EMAIL_PASSWORD, + SMTP_HOST: process.env.SMTP_HOST, + SMTP_PORT: parseInt(process.env.SMTP_PORT), + SMTP_SECURE: process.env.SMTP_SECURE === 'true', + SMTP_USER: process.env.SMTP_USER, + SMTP_PASSWORD: process.env.SMTP_PASSWORD, }), ); diff --git a/libs/common/src/util/email.service.ts b/libs/common/src/util/email.service.ts index f181de8..8636dea 100644 --- a/libs/common/src/util/email.service.ts +++ b/libs/common/src/util/email.service.ts @@ -4,12 +4,18 @@ import * as nodemailer from 'nodemailer'; @Injectable() export class EmailService { - private user: string; - private pass: string; + private smtpConfig: any; constructor(private readonly configService: ConfigService) { - this.user = this.configService.get('email-config.EMAIL_ID'); - this.pass = this.configService.get('email-config.PASSWORD'); + this.smtpConfig = { + host: this.configService.get('email-config.SMTP_HOST'), + port: this.configService.get('email-config.SMTP_PORT'), + secure: this.configService.get('email-config.SMTP_SECURE'), // true for 465, false for other ports + auth: { + user: this.configService.get('email-config.SMTP_USER'), + pass: this.configService.get('email-config.SMTP_PASSWORD'), + }, + }; } async sendOTPEmail( @@ -17,17 +23,10 @@ export class EmailService { subject: string, message: string, ): Promise { - - const transporter = nodemailer.createTransport({ - service: 'gmail', - auth: { - user: this.user, - pass: this.pass, - }, - }); + const transporter = nodemailer.createTransport(this.smtpConfig); const mailOptions = { - from: this.user, + from: this.smtpConfig.auth.user, to: email, subject, text: message,