27 lines
721 B
TypeScript
27 lines
721 B
TypeScript
import { Injectable, Logger } from '@nestjs/common';
|
|
import { SentEmail } from './mail.types';
|
|
|
|
@Injectable()
|
|
export class MailService {
|
|
private readonly logger = new Logger(MailService.name);
|
|
private readonly sentEmails: SentEmail[] = [];
|
|
|
|
sendVerificationEmail(to: string, verificationUrl: string): void {
|
|
const email: SentEmail = {
|
|
to,
|
|
subject: 'Verify your Listify account',
|
|
text: `Please verify your account by opening this link: ${verificationUrl}`,
|
|
verificationUrl,
|
|
};
|
|
|
|
this.sentEmails.push(email);
|
|
this.logger.log(
|
|
`Verification email sent to ${to}: ${email.verificationUrl}`,
|
|
);
|
|
}
|
|
|
|
getSentEmails(): SentEmail[] {
|
|
return [...this.sentEmails];
|
|
}
|
|
}
|