Initial
This commit is contained in:
26
listify-api/src/mail/mail.service.ts
Normal file
26
listify-api/src/mail/mail.service.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
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];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user