forked from Yara724/api
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { Injectable } from "@nestjs/common";
|
|
import { MailerService } from "@nestjs-modules/mailer";
|
|
|
|
@Injectable()
|
|
export class MailService {
|
|
constructor(private readonly mailerService: MailerService) {}
|
|
async sendMail(email, otp: string): Promise<any> {
|
|
let status: object;
|
|
await this.mailerService
|
|
.sendMail({
|
|
to: email,
|
|
from: "noreply@yara724.com",
|
|
subject: "YARA724 Company",
|
|
text: "welcome",
|
|
html: `
|
|
<h1 style="text-align:center">yara724 verificateion </h1>
|
|
<h3 style="background:#FFA500;width:150px; margin:0 auto; padding:10px; font-size:25px; border-radius:15px; text-align:center;">
|
|
<div style="color:white">
|
|
${otp}
|
|
</div>
|
|
</h3>
|
|
`,
|
|
})
|
|
.then((success) => {
|
|
if (success) {
|
|
status = {
|
|
message: "email was sent successfully",
|
|
code: 200,
|
|
emailSent: true,
|
|
};
|
|
}
|
|
})
|
|
.catch((err) => {
|
|
if (err) {
|
|
status = { message: "please try again", code: 500, emailSent: false };
|
|
}
|
|
});
|
|
|
|
return status;
|
|
}
|
|
}
|