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 { let status: object; await this.mailerService .sendMail({ to: email, from: "noreply@yara724.com", subject: "YARA724 Company", text: "welcome", html: `

yara724 verificateion

${otp}

`, }) .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; } }