correction responsive
This commit is contained in:
@@ -75,7 +75,7 @@ export async function scheduleUserDeletion(userId: string, reason: string, delay
|
||||
|
||||
// Send notification email
|
||||
if (settings?.deleteAccountTemplate) {
|
||||
const { sendEmail } = await import("@/../../lib/mail");
|
||||
const { sendEmail } = await import("@/lib/mail");
|
||||
const html = settings.deleteAccountTemplate
|
||||
.replace(/{name}/g, user.name)
|
||||
.replace(/{siteName}/g, settings.siteName)
|
||||
@@ -114,7 +114,7 @@ export async function reactivateUser(userId: string, reason: string) {
|
||||
|
||||
// Send confirmation email
|
||||
if (settings?.reactivateAccountTemplate) {
|
||||
const { sendEmail } = await import("@/../../lib/mail");
|
||||
const { sendEmail } = await import("@/lib/mail");
|
||||
const html = settings.reactivateAccountTemplate
|
||||
.replace(/{name}/g, user.name)
|
||||
.replace(/{siteName}/g, settings.siteName)
|
||||
|
||||
38
admin/src/lib/mail.ts
Normal file
38
admin/src/lib/mail.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import nodemailer from 'nodemailer';
|
||||
|
||||
console.log('SMTP Config:', {
|
||||
host: process.env.SMTP_HOST,
|
||||
port: process.env.SMTP_PORT,
|
||||
secure: process.env.SMTP_SECURE,
|
||||
user: process.env.SMTP_USER
|
||||
});
|
||||
const transporter = nodemailer.createTransport({
|
||||
host: process.env.SMTP_HOST,
|
||||
port: parseInt(process.env.SMTP_PORT || '587'),
|
||||
secure: process.env.SMTP_SECURE === 'true',
|
||||
auth: {
|
||||
user: process.env.SMTP_USER,
|
||||
pass: process.env.SMTP_PASS,
|
||||
},
|
||||
tls: {
|
||||
rejectUnauthorized: false
|
||||
}
|
||||
});
|
||||
|
||||
export const sendEmail = async ({ to, subject, html }: { to: string; subject: string; html: string }) => {
|
||||
const mailOptions = {
|
||||
from: process.env.SMTP_FROM || '"Afrohub" <noreply@afrohub.com>',
|
||||
to,
|
||||
subject,
|
||||
html,
|
||||
};
|
||||
|
||||
try {
|
||||
const info = await transporter.sendMail(mailOptions);
|
||||
console.log('Email sent: ' + info.response);
|
||||
return info;
|
||||
} catch (error) {
|
||||
console.error('Error sending email:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user