mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-10 15:17:41 +00:00
change to smtp mailer
This commit is contained in:
@ -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<string>('email-config.EMAIL_ID');
|
||||
this.pass = this.configService.get<string>('email-config.PASSWORD');
|
||||
this.smtpConfig = {
|
||||
host: this.configService.get<string>('email-config.SMTP_HOST'),
|
||||
port: this.configService.get<number>('email-config.SMTP_PORT'),
|
||||
secure: this.configService.get<boolean>('email-config.SMTP_SECURE'), // true for 465, false for other ports
|
||||
auth: {
|
||||
user: this.configService.get<string>('email-config.SMTP_USER'),
|
||||
pass: this.configService.get<string>('email-config.SMTP_PASSWORD'),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
async sendOTPEmail(
|
||||
@ -17,17 +23,10 @@ export class EmailService {
|
||||
subject: string,
|
||||
message: string,
|
||||
): Promise<void> {
|
||||
|
||||
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,
|
||||
|
Reference in New Issue
Block a user