import dotenv from 'dotenv';
import { sendWelcomeEmail } from './utils/emailService.js';

// Load environment variables
dotenv.config();

console.log('🧪 Testing Signup Email Functionality\n');
console.log('📧 Email Configuration:');
console.log('   SMTP Host:', process.env.SMTP_HOST || 'Not set');
console.log('   SMTP Port:', process.env.SMTP_PORT || 'Not set');
console.log('   SMTP User:', process.env.SMTP_USER || 'Not set');
console.log('   Google App Email:', process.env.GOOGLE_APP_EMAIL || 'Not set');
console.log('   Google App Passcode:', process.env.GOOGLE_APP_PASSCODE ? '✅ Set' : '❌ Not set');
console.log('\n');

// Test email sending
const testEmail = async () => {
    try {
        console.log('📨 Sending test welcome email...');
        
        // Use your email for testing - change this to your actual email
        const testUserEmail = 'developer0031@gmail.com'; // ⚠️ CHANGE THIS
        const testUserName = 'Test User';
        
        console.log(`📬 Sending to: ${testUserEmail}`);
        console.log(`👤 User name: ${testUserName}\n`);
        
        await sendWelcomeEmail(testUserEmail, testUserName);
        
        console.log('\n✅ Test completed! Check the console output above for any errors.');
        console.log('📬 If successful, check your email inbox (and spam folder).');
    } catch (error) {
        console.error('\n❌ Test failed with error:', error.message);
        console.error('Full error:', error);
    }
};

testEmail();
