chore: add verfication email for user profile

This commit is contained in:
mahyargdz
2025-02-18 10:16:05 +03:30
parent ff96fd6c32
commit cad8e15941
15 changed files with 173 additions and 31 deletions
+6 -5
View File
@@ -1,5 +1,6 @@
import { Injectable, Logger } from "@nestjs/common";
import { Injectable, InternalServerErrorException, Logger } from "@nestjs/common";
import { MailerService } from "@nestjs-modules/mailer";
import { SentMessageInfo } from "nodemailer";
import { EmailMessage } from "../../../common/enums/message.enum";
@@ -8,12 +9,12 @@ export class EmailService {
private readonly logger = new Logger(EmailService.name);
constructor(private readonly mailerService: MailerService) {}
async sendEmail(to: string, subject: string, link: string, fullName: string) {
async sendVerificationEmail(to: string, link: string, fullName: string): Promise<SentMessageInfo> {
try {
const emailInfo = await this.mailerService.sendMail({
to: to,
// from: "noreply@nestjs.com",
subject: subject,
subject: EmailMessage.EMAIL_VERIFICATION,
template: "email-verify",
context: {
title: EmailMessage.EMAIL_VERIFICATION,
@@ -24,7 +25,7 @@ export class EmailService {
return emailInfo;
} catch (error) {
this.logger.error("Email sending failed:", error);
return false;
throw new InternalServerErrorException(EmailMessage.EMAIL_SENDING_FAILED);
}
}
}