| Server IP : 65.1.209.187 / Your IP : 216.73.216.144 Web Server : nginx/1.24.0 System : Linux ip-172-31-5-206 6.14.0-1015-aws #15~24.04.1-Ubuntu SMP Tue Sep 23 22:44:48 UTC 2025 x86_64 User : ( 1001) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/drjunior_wordpress/wp-content/themes/drjunior/ |
Upload File : |
<?php
/**
* Email Configuration Diagnostic Tool
*
* SECURITY WARNING: Delete this file after testing!
* This file should NOT be left on production servers.
*
* Usage: Upload to your server and access via browser
* Example: https://yoursite.com/wp-content/themes/drjunior/test-mail-config.php
*/
// Prevent direct access without a secret key
$secret_key = 'test123'; // Change this to something unique
if (!isset($_GET['key']) || $_GET['key'] !== $secret_key) {
die('Access denied. Add ?key=' . $secret_key . ' to the URL');
}
// Load WordPress if available
$wp_loaded = false;
if (file_exists('../../../wp-load.php')) {
require_once('../../../wp-load.php');
$wp_loaded = true;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Email Configuration Diagnostics</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; background: #f5f5f5; }
.container { max-width: 900px; margin: 0 auto; background: white; padding: 20px; border-radius: 8px; }
h1 { color: #008da6; border-bottom: 3px solid #008da6; padding-bottom: 10px; }
h2 { color: #333; margin-top: 30px; }
.section { background: #f9f9f9; padding: 15px; margin: 15px 0; border-left: 4px solid #008da6; }
.success { color: #28a745; font-weight: bold; }
.error { color: #dc3545; font-weight: bold; }
.warning { color: #ffc107; font-weight: bold; }
.info { color: #17a2b8; }
table { width: 100%; border-collapse: collapse; margin: 10px 0; }
table td { padding: 8px; border: 1px solid #ddd; }
table td:first-child { font-weight: bold; width: 250px; background: #f5f5f5; }
.test-form { background: #e8f4f8; padding: 20px; border-radius: 5px; margin: 20px 0; }
input[type="email"] { width: 100%; padding: 8px; margin: 5px 0; }
button { background: #008da6; color: white; padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; }
button:hover { background: #006d7f; }
.code { background: #f4f4f4; padding: 2px 6px; border-radius: 3px; font-family: monospace; }
</style>
</head>
<body>
<div class="container">
<h1>📧 Email Configuration Diagnostics</h1>
<p><strong>WARNING:</strong> <span class="error">Delete this file after testing!</span> This file contains sensitive server information.</p>
<!-- Server Environment -->
<h2>🖥️ Server Environment</h2>
<div class="section">
<table>
<tr>
<td>PHP Version</td>
<td><?php echo phpversion(); ?></td>
</tr>
<tr>
<td>Server Software</td>
<td><?php echo $_SERVER['SERVER_SOFTWARE'] ?? 'Unknown'; ?></td>
</tr>
<tr>
<td>WordPress Loaded</td>
<td><?php echo $wp_loaded ? '<span class="success">✓ Yes</span>' : '<span class="error">✗ No</span>'; ?></td>
</tr>
<?php if ($wp_loaded): ?>
<tr>
<td>WordPress Version</td>
<td><?php echo get_bloginfo('version'); ?></td>
</tr>
<?php endif; ?>
</table>
</div>
<!-- PHP Mail Configuration -->
<h2>📮 PHP Mail Configuration</h2>
<div class="section">
<table>
<tr>
<td>mail() function</td>
<td>
<?php
if (function_exists('mail')) {
echo '<span class="success">✓ Available</span>';
} else {
echo '<span class="error">✗ Not available</span>';
}
?>
</td>
</tr>
<?php if ($wp_loaded): ?>
<tr>
<td>wp_mail() function</td>
<td>
<?php
if (function_exists('wp_mail')) {
echo '<span class="success">✓ Available</span>';
} else {
echo '<span class="error">✗ Not available</span>';
}
?>
</td>
</tr>
<?php endif; ?>
<tr>
<td>sendmail_path</td>
<td>
<?php
$sendmail = ini_get('sendmail_path');
if (empty($sendmail) || $sendmail === 'null') {
echo '<span class="error">✗ Not configured</span>';
} else {
echo '<span class="success">✓ ' . htmlspecialchars($sendmail) . '</span>';
}
?>
</td>
</tr>
<tr>
<td>SMTP (Windows)</td>
<td><?php echo ini_get('SMTP') ?: '<span class="warning">Not set (Linux servers use sendmail)</span>'; ?></td>
</tr>
<tr>
<td>smtp_port (Windows)</td>
<td><?php echo ini_get('smtp_port') ?: '<span class="warning">Not set</span>'; ?></td>
</tr>
<tr>
<td>sendmail_from</td>
<td><?php echo ini_get('sendmail_from') ?: '<span class="warning">Not set</span>'; ?></td>
</tr>
</table>
</div>
<!-- Recommendations -->
<h2>💡 Recommendations</h2>
<div class="section">
<?php
$issues = [];
$sendmail = ini_get('sendmail_path');
if (!function_exists('mail')) {
$issues[] = '<strong>Critical:</strong> mail() function is disabled. Contact your hosting provider.';
}
if (empty($sendmail) || $sendmail === 'null') {
$issues[] = '<strong>Warning:</strong> sendmail_path is not configured in php.ini. This may cause mail() to fail.';
}
if ($wp_loaded && function_exists('wp_mail')) {
echo '<p class="info">✓ WordPress is loaded and wp_mail() is available. This is the recommended method.</p>';
}
if (empty($issues)) {
echo '<p class="success">✓ No major issues detected with your mail configuration!</p>';
} else {
foreach ($issues as $issue) {
echo '<p class="error">✗ ' . $issue . '</p>';
}
}
?>
<h3>Common Solutions:</h3>
<ul>
<li>If using shared hosting, ensure sendmail or SMTP is enabled in your hosting control panel</li>
<li>Consider using an SMTP plugin like "WP Mail SMTP" or "Easy WP SMTP"</li>
<li>Check if your server's IP is blacklisted (may cause silent failures)</li>
<li>Verify that your hosting provider allows outbound email</li>
<li>Check mail logs: usually at <span class="code">/var/log/mail.log</span> or <span class="code">/var/log/maillog</span></li>
</ul>
</div>
<!-- Test Email -->
<h2>📨 Send Test Email</h2>
<div class="section">
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['test_email'])) {
$test_email = filter_var($_POST['test_email'], FILTER_VALIDATE_EMAIL);
if ($test_email) {
$test_subject = 'Test Email from Dr. Junior - ' . date('Y-m-d H:i:s');
$test_message = '<html><body>';
$test_message .= '<h2>Test Email</h2>';
$test_message .= '<p>This is a test email sent from your Dr. Junior website.</p>';
$test_message .= '<p><strong>Sent at:</strong> ' . date('Y-m-d H:i:s') . '</p>';
$test_message .= '<p><strong>Server:</strong> ' . ($_SERVER['SERVER_NAME'] ?? 'Unknown') . '</p>';
$test_message .= '</body></html>';
$test_headers = [
'Content-Type: text/html; charset=UTF-8',
'From: Dr. Junior <mailer@drjunior.in>'
];
$result = false;
$method = '';
// Try wp_mail first
if ($wp_loaded && function_exists('wp_mail')) {
$result = wp_mail($test_email, $test_subject, $test_message, $test_headers);
$method = 'wp_mail';
}
// Fallback to mail()
if (!$result && function_exists('mail')) {
$result = mail($test_email, $test_subject, $test_message, implode("\r\n", $test_headers));
$method = 'mail';
}
if ($result) {
echo '<div style="padding: 15px; background: #d4edda; border: 1px solid #c3e6cb; border-radius: 4px; color: #155724;">';
echo '<strong>✓ Success!</strong> Test email sent to ' . htmlspecialchars($test_email) . ' using ' . $method . '()<br>';
echo 'Check your inbox (and spam folder) in a few minutes.';
echo '</div>';
} else {
echo '<div style="padding: 15px; background: #f8d7da; border: 1px solid #f5c6cb; border-radius: 4px; color: #721c24;">';
echo '<strong>✗ Failed!</strong> Could not send test email.<br>';
echo 'Method attempted: ' . ($method ?: 'None available') . '<br>';
echo 'Check the error log at: <span class="code">wp-content/themes/drjunior/ajax-form-debug.log</span>';
echo '</div>';
}
} else {
echo '<div style="padding: 15px; background: #fff3cd; border: 1px solid #ffeaa7; border-radius: 4px; color: #856404;">';
echo '<strong>⚠ Warning!</strong> Invalid email address provided.';
echo '</div>';
}
}
?>
<div class="test-form">
<form method="POST">
<label for="test_email"><strong>Enter your email address to receive a test email:</strong></label>
<input type="email" id="test_email" name="test_email" required placeholder="your.email@example.com">
<button type="submit">Send Test Email</button>
</form>
</div>
</div>
<!-- Security Reminder -->
<div class="section" style="border-left-color: #dc3545; background: #ffe6e6;">
<h3 style="color: #dc3545;">🔒 Security Reminder</h3>
<p><strong>Important:</strong> Delete this file (<span class="code">test-mail-config.php</span>) after testing!</p>
<p>This file exposes server configuration details and should not be accessible on production servers.</p>
</div>
</div>
</body>
</html>