// Debug script to check SMTP configuration // Run with: node debug-smtp.js import { initializeApp } from 'firebase/app'; import { getFirestore, doc, getDoc } from 'firebase/firestore'; const firebaseConfig = { apiKey: "AIzaSyAHtvhdtBxNwf0UE3Fp5P0v1vITZKhLMJw", authDomain: "prayer-app-6701f.firebaseapp.com", projectId: "prayer-app-6701f", storageBucket: "prayer-app-6701f.firebasestorage.app", messagingSenderId: "555011794707", appId: "1:555011794707:web:a3d60bdee742578cca1ce6" }; const app = initializeApp(firebaseConfig); const db = getFirestore(app); async function debugSMTP() { try { console.log('🔍 Checking SMTP configuration in Firestore...'); const configDoc = await getDoc(doc(db, 'config', 'smtp')); if (configDoc.exists()) { const config = configDoc.data(); console.log('✅ SMTP config found:'); console.log(` Host: ${config.host || 'MISSING'}`); console.log(` Port: ${config.port || 'MISSING'}`); console.log(` Secure: ${config.secure}`); console.log(` User: ${config.user ? 'Set' : 'MISSING'}`); console.log(` Pass: ${config.pass ? 'Set' : 'MISSING'}`); console.log(` From: ${config.from || 'MISSING'}`); // Check for common issues if (!config.host) console.log('❌ ERROR: Host is missing'); if (!config.port) console.log('❌ ERROR: Port is missing'); if (!config.user) console.log('❌ ERROR: Username is missing'); if (!config.pass) console.log('❌ ERROR: Password is missing'); if (!config.from) console.log('❌ ERROR: From email is missing'); if (config.host && config.port && config.user && config.pass && config.from) { console.log('✅ Configuration looks complete'); console.log('💡 If email still fails, check:'); console.log(' - SMTP server credentials are correct'); console.log(' - Firewall/antivirus not blocking connection'); console.log(' - Gmail: Using App Password (not regular password)'); } } else { console.log('❌ SMTP configuration not found in Firestore!'); console.log('💡 Set it up in Admin panel: http://localhost:3000/admin'); } } catch (error) { console.error('❌ Error checking SMTP config:', error.message); if (error.code === 'permission-denied') { console.log('💡 Permission denied - make sure Firestore rules allow config access'); } } } debugSMTP();