forked from Yara724/api
Initial commit after migration to gitea
This commit is contained in:
41
src/utils/mail/mail.service.ts
Normal file
41
src/utils/mail/mail.service.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user