chore: add verfication email for user profile
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user