initial release
This commit is contained in:
24
bizmatch-server/src/mail/mail.service.ts
Normal file
24
bizmatch-server/src/mail/mail.service.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { MailerService } from '@nestjs-modules/mailer';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { AuthService } from '../auth/auth.service.js';
|
||||
import { MailInfo } from '../models/server.model.js';
|
||||
import { User } from 'src/models/main.model.js';
|
||||
|
||||
@Injectable()
|
||||
export class MailService {
|
||||
constructor(private mailerService: MailerService, private authService:AuthService) {}
|
||||
|
||||
async sendInquiry(userId:string,mailInfo: MailInfo) {
|
||||
const user = await this.authService.getUser(userId) as User;
|
||||
await this.mailerService.sendMail({
|
||||
to: user.email,
|
||||
from: '"Bizmatch Team" <info@bizmatch.net>', // override default from
|
||||
subject: `Inquiry from ${mailInfo.sender.name}`,
|
||||
template: './inquiry', // `.hbs` extension is appended automatically
|
||||
context: { // ✏️ filling curly brackets with content
|
||||
name: user.firstname,
|
||||
inquiry:mailInfo.sender.comments
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user