import * as nodemailer from 'nodemailer';
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { Transporter } from 'nodemailer';

@Injectable()
export class MailService {
  private transporter: Transporter;

  constructor(private configService: ConfigService) {
    this.transporter = nodemailer.createTransport({
      host: this.configService.get<string>('MAIL_HOST'),
      port: Number(this.configService.get<string>('MAIL_PORT')),
      secure: false,
      auth: {
        user: this.configService.get<string>('MAIL_USER'),
        pass: this.configService.get<string>('MAIL_PASS'),
      },
    });
  }

  async sendMail(to: string, subject: string, html: string) {
    // const adminEmail = this.configService.get<string>('ADMIN_EMAIL') || 'admin@trytalento.com';
    // await this.transporter.sendMail({
    //   from: this.configService.get<string>('MAIL_FROM'),
    //   to,
    //   cc: to !== adminEmail ? adminEmail : undefined,
    //   subject,
    //   html,
    // });
  }
}