Files
MinglarBackendNestJS/src/modules/host/services/sendOTPEmail.service.ts
2026-04-14 13:28:46 +05:30

102 lines
2.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { brevoService } from '../../../common/email/brevoApi';
import ApiError from '../../../common/utils/helper/ApiError';
import config from '../../../config/config';
export async function sendOtpEmailForHost(
emailAddress: string,
otp: string | number,
): Promise<{
sent: boolean;
// messageId: string
}> {
const subject = 'Your Minglar Verification Code';
const htmlContent = `
<p>Hi there 👋</p>
<p>Heres your verification code to get started:</p>
<p><strong>${otp}</strong></p>
<p>This code is valid for the next 5 minutes.</p>
<p>Once verified, you can continue setting up your Minglar account. If you didnt request this, you can safely ignore this email.</p>
<p>Need help? Reach out to us at info@minglargroup.com.</p>
<p>Warm regards,<br />Team Minglar</p>
`;
try {
const result = await brevoService.sendEmail({
recipients: [{ email: emailAddress }],
subject,
htmlContent,
});
// console.log("📧 Email sent successfully:", result);
return {
sent: true,
// messageId: result.messageId
};
} catch (err) {
console.error('Brevo email send failed:', err);
throw new ApiError(500, 'Failed to send OTP to host via email.');
}
}
export async function sendWelcomeEmailToHost(emailAddress: string): Promise<{
sent: boolean;
// messageId: string
}> {
const subject = 'Get Started as a Minglar Host';
const htmlContent = `
<p>Hi ${emailAddress},</p>
<p>Were excited to have you join Minglar as a host. Welcome aboard! 🌟</p>
<p>To get started and bring your activities live, heres what comes next:</p>
<p><strong>Your next steps:</strong></p>
<p>1. Complete your host profile</p>
<p>2. Complete the pre-qualification process for all your activities</p>
<p>3. Submit your activity details for review</p>
<p>4. Go live and start receiving bookings</p>
<p>
👉 <strong>Access your Host Portal:</strong><br/>
<a href="${config.HOST_LINK}" target="_blank">${config.HOST_LINK}</a>
</p>
<p>
If you need any support along the way, our team is always here to help.
You can reach us anytime at
<a href="mailto:info@minglargroup.com">info@minglargroup.com</a>.
</p>
<p>
Were looking forward to seeing your experiences come to life on Minglar.
</p>
<p>
Warm regards,<br/>
Team Minglar
</p>
`;
try {
const result = await brevoService.sendEmail({
recipients: [{ email: emailAddress }],
subject,
htmlContent,
});
// console.log("📧 Email sent successfully:", result);
return {
sent: true,
// messageId: result.messageId
};
} catch (err) {
console.error('Brevo email send failed:', err);
throw new ApiError(500, 'Failed to send OTP to host via email.');
}
}