import "dotenv/config";

console.log("🔍 Checking SMTP Email Configuration...\n");

const SMTP_HOST = process.env.SMTP_HOST;
const SMTP_PORT = process.env.SMTP_PORT || "465";
const SMTP_USER = process.env.SMTP_USER;
const SMTP_PASS = process.env.SMTP_PASS;
const ADMIN_EMAIL = process.env.ADMIN_EMAIL;
const COMPANY_EMAIL = process.env.COMPANY_EMAIL;

console.log("SMTP Configuration:");
console.log(`   SMTP_HOST: ${SMTP_HOST || "❌ NOT SET"}`);
console.log(`   SMTP_PORT: ${SMTP_PORT}`);
console.log(`   SMTP_USER: ${SMTP_USER || "❌ NOT SET"}`);
console.log(`   SMTP_PASS: ${SMTP_PASS ? "✓ (hidden)" : "❌ NOT SET"}`);
console.log(`   ADMIN_EMAIL: ${ADMIN_EMAIL || "⚠️  NOT SET (optional)"}`);
console.log(`   COMPANY_EMAIL: ${COMPANY_EMAIL || "⚠️  NOT SET (optional)"}`);

const required = ["SMTP_HOST", "SMTP_USER", "SMTP_PASS"];
const missing = required.filter((key) => !process.env[key]);

if (missing.length > 0) {
  console.log(`\n❌ Missing required SMTP credentials: ${missing.join(", ")}`);
  console.log("\nTo fix this:");
  console.log("   1. Ensure SMTP_HOST, SMTP_USER, and SMTP_PASS are set in Backend/.env");
  console.log("   2. Run 'npm run copy-zoom-credentials' to copy from aibit_soft/.env.local");
  console.log("   3. Restart your backend server after updating .env");
  process.exit(1);
}

console.log("\n✅ All required SMTP credentials are configured!");
console.log("\n📝 Note: If emails are still not being sent:");
console.log("   1. Verify your SMTP credentials are correct");
console.log("   2. For Gmail, ensure you're using an App Password (not your regular password)");
console.log("   3. Check your backend server logs for email error messages");
console.log("   4. Ensure your firewall/network allows SMTP connections");

