Auspicious14 commited on
Commit
18f4675
·
1 Parent(s): a8daede

fix(email): parse SMTP port as integer and increase timeouts

Browse files

- Parse SMTP_PORT to integer with fallback to 465 to prevent type errors
- Increase connection and greeting timeouts from 10s to 20s for reliability
- Add debug logging and TLS option to help diagnose SMTP connection issues

Files changed (1) hide show
  1. src/notifications/email.service.ts +8 -3
src/notifications/email.service.ts CHANGED
@@ -10,18 +10,23 @@ export class EmailService {
10
  constructor(private readonly configService: ConfigService) {
11
  this.transporter = nodemailer.createTransport({
12
  host: this.configService.get("SMTP_HOST"),
13
- port: this.configService.get("SMTP_PORT"),
14
  secure: this.configService.get("SMTP_SECURE") === "true",
15
  pool: true,
16
  maxConnections: 5,
17
  maxMessages: 100,
18
- connectionTimeout: 10000, // 10 seconds
19
- greetingTimeout: 10000,
20
  socketTimeout: 30000,
 
 
21
  auth: {
22
  user: this.configService.get("SMTP_USER"),
23
  pass: this.configService.get("SMTP_PASS"),
24
  },
 
 
 
25
  });
26
  }
27
 
 
10
  constructor(private readonly configService: ConfigService) {
11
  this.transporter = nodemailer.createTransport({
12
  host: this.configService.get("SMTP_HOST"),
13
+ port: parseInt(this.configService.get("SMTP_PORT") || "465", 10),
14
  secure: this.configService.get("SMTP_SECURE") === "true",
15
  pool: true,
16
  maxConnections: 5,
17
  maxMessages: 100,
18
+ connectionTimeout: 20000,
19
+ greetingTimeout: 20000,
20
  socketTimeout: 30000,
21
+ debug: true,
22
+ logger: true,
23
  auth: {
24
  user: this.configService.get("SMTP_USER"),
25
  pass: this.configService.get("SMTP_PASS"),
26
  },
27
+ tls: {
28
+ rejectUnauthorized: false, // Help with some SMTP issues
29
+ },
30
  });
31
  }
32