Sindbad~EG File Manager

Current Path : /home/copmadinaarea/thecopmadinaarea.org/portal/
Upload File :
Current File : /home/copmadinaarea/thecopmadinaarea.org/portal/check_email_config.php

<?php
/**
 * Email Configuration Checker
 * Run this to diagnose email sending issues
 */

require_once 'config/config.php';
require_once 'classes/EmailService.php';

// Only allow logged in admins
if (!isLoggedIn() || !isSuperuser()) {
    die('Access denied. Superuser access required.');
}

$emailService = new EmailService();
$db = Database::getInstance()->getConnection();

// Get email settings
$stmt = $db->query("SELECT * FROM email_settings ORDER BY id DESC LIMIT 1");
$settings = $stmt->fetch(PDO::FETCH_ASSOC);

?>
<!DOCTYPE html>
<html>
<head>
    <title>Email Configuration Check</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 900px;
            margin: 50px auto;
            padding: 20px;
            background: #f5f5f5;
        }
        .card {
            background: white;
            padding: 30px;
            border-radius: 16px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.1);
            margin-bottom: 20px;
        }
        .status {
            padding: 15px;
            border-radius: 8px;
            margin: 10px 0;
        }
        .success {
            background: #d1fae5;
            border: 2px solid #10b981;
            color: #047857;
        }
        .error {
            background: #fee2e2;
            border: 2px solid #ef4444;
            color: #991b1b;
        }
        .warning {
            background: #fef3c7;
            border: 2px solid #f59e0b;
            color: #92400e;
        }
        .info {
            background: #e0e7ff;
            border: 2px solid #6366f1;
            color: #3730a3;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin: 20px 0;
        }
        th, td {
            padding: 12px;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }
        th {
            background: #f9fafb;
            font-weight: bold;
        }
        .hidden {
            filter: blur(5px);
            cursor: pointer;
            user-select: none;
        }
        .btn {
            display: inline-block;
            padding: 10px 20px;
            background: linear-gradient(135deg, #1E40AF 0%, #9333EA 100%);
            color: white;
            text-decoration: none;
            border-radius: 8px;
            margin: 10px 5px;
        }
    </style>
</head>
<body>
    <div class="card">
        <h1>📧 Email Configuration Check</h1>
        
        <!-- Email Service Status -->
        <?php if ($settings): ?>
            <?php if ($settings['is_enabled'] == 1): ?>
                <div class="status success">
                    <h3>✅ Email Service: ENABLED</h3>
                    <p>Email service is active and ready to send emails.</p>
                </div>
            <?php else: ?>
                <div class="status error">
                    <h3>❌ Email Service: DISABLED</h3>
                    <p><strong>Problem:</strong> Email service is disabled in settings.</p>
                    <p><strong>Solution:</strong> Go to Email Settings and enable email service.</p>
                </div>
            <?php endif; ?>
        <?php else: ?>
            <div class="status error">
                <h3>❌ No Email Settings Found</h3>
                <p><strong>Problem:</strong> email_settings table is empty.</p>
                <p><strong>Solution:</strong> Configure email settings in admin panel.</p>
            </div>
        <?php endif; ?>
    </div>

    <?php if ($settings): ?>
    <div class="card">
        <h2>📋 Current Email Settings</h2>
        
        <table>
            <tr>
                <th>Setting</th>
                <th>Value</th>
            </tr>
            <tr>
                <td><strong>SMTP Host</strong></td>
                <td><?php echo htmlspecialchars($settings['smtp_host']); ?></td>
            </tr>
            <tr>
                <td><strong>SMTP Port</strong></td>
                <td><?php echo htmlspecialchars($settings['smtp_port']); ?></td>
            </tr>
            <tr>
                <td><strong>SMTP Username</strong></td>
                <td><?php echo htmlspecialchars($settings['smtp_username']); ?></td>
            </tr>
            <tr>
                <td><strong>SMTP Password</strong></td>
                <td>
                    <span class="hidden" onclick="this.classList.remove('hidden')">
                        <?php echo htmlspecialchars($settings['smtp_password']); ?>
                    </span>
                    <small>(Click to reveal)</small>
                </td>
            </tr>
            <tr>
                <td><strong>Encryption</strong></td>
                <td><?php echo htmlspecialchars($settings['smtp_encryption']); ?></td>
            </tr>
            <tr>
                <td><strong>From Email</strong></td>
                <td><?php echo htmlspecialchars($settings['from_email']); ?></td>
            </tr>
            <tr>
                <td><strong>From Name</strong></td>
                <td><?php echo htmlspecialchars($settings['from_name']); ?></td>
            </tr>
        </table>
    </div>
    <?php endif; ?>

    <div class="card">
        <h2>🔍 Common Issues & Solutions</h2>
        
        <div class="info">
            <h3>Issue 1: Email service not enabled</h3>
            <p><strong>Check:</strong> is_enabled = 1 in email_settings table</p>
            <p><strong>Fix:</strong> Enable email service in admin panel Email Settings</p>
        </div>
        
        <div class="info">
            <h3>Issue 2: SMTP not configured</h3>
            <p><strong>Check:</strong> SMTP host, port, username, password are set</p>
            <p><strong>Fix:</strong> Configure SMTP settings in Email Settings module</p>
        </div>
        
        <div class="info">
            <h3>Issue 3: Symfony Mailer not installed</h3>
            <p><strong>Check:</strong> Run <code>composer require symfony/mailer</code></p>
            <p><strong>Fix:</strong> Install Symfony Mailer via Composer</p>
        </div>
        
        <div class="info">
            <h3>Issue 4: SMTP credentials incorrect</h3>
            <p><strong>Check:</strong> Test with fix_smtp_settings.php</p>
            <p><strong>Fix:</strong> Update SMTP credentials</p>
        </div>
    </div>

    <div class="card">
        <h2>🔗 Quick Actions</h2>
        <a href="fix_smtp_settings.php" class="btn">🔧 Fix SMTP Settings</a>
        <a href="dashboard.php" class="btn">🏠 Back to Dashboard</a>
        <a href="modules/email/settings.php" class="btn">⚙️ Email Settings</a>
    </div>

    <div class="card">
        <h2>📝 Check PHP Error Log</h2>
        <p>Password reset emails now log errors. Check your PHP error log for messages like:</p>
        <ul>
            <li><code>Password Reset Email Failed: Email service is not enabled</code></li>
            <li><code>Attempting to send password reset email to: user@example.com</code></li>
            <li><code>Password reset email sent successfully to: user@example.com</code></li>
            <li><code>Password reset email failed to send to: user@example.com</code></li>
        </ul>
        <p><strong>Log location:</strong> Check XAMPP error logs or <code>php_error.log</code></p>
    </div>
</body>
</html>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists