import { Injectable, Post, Body } from '@nestjs/common'; import { MailerService } from '@nestjs-modules/mailer'; @Injectable() export class EmailService { constructor(private mailerService: MailerService) {} async sendWelcomeEmail(email: string, name: string) { await this.mailerService.sendMail({ to: email, subject: 'Welcome to IMK Platform', html: `

Welcome to IMK Platform!

Dear ${name},

Thank you for joining IMK Platform. Your account has been created successfully.

You can now log in to access your documents and start collaborating with your team.

If you have any questions or need assistance, please don't hesitate to contact our support team.

Login to Your Account

Best regards,
IMK Team

`, }); } async sendPasswordResetEmail(email: string, resetToken: string) { const resetLink = `${process.env.FRONTEND_URL}/reset-password?token=${resetToken}`; await this.mailerService.sendMail({ to: email, subject: 'Password Reset Request', html: `

Password Reset

Click the link below to reset your password:

Reset Password

This link will expire in 1 hour.

`, }); } async sendDocumentSharedNotification(email: string, documentTitle: string, sharedByName: string) { await this.mailerService.sendMail({ to: email, subject: 'New Document Shared With You', html: `

New Document Available

${sharedByName} has shared a document with you: "${documentTitle}"

Login to your account to view the document.

`, }); } async sendContactEmail(name: string, email: string, message: string) { // Send to admin await this.mailerService.sendMail({ to: process.env.ADMIN_EMAIL, subject: `New Contact Form Submission from ${name}`, html: `

New Contact Form Submission

From: ${name}

Email: ${email}

Message:

${message}

`, }); await this.mailerService.sendMail({ to: email, subject: 'Thank you for contacting us', html: `

Thank you for contacting us

Dear ${name},

We have received your message and will get back to you soon.

Your message:

${message}

Best regards,
IMK Team

`, }); } }