SMTP Email Debugger
Troubleshoot SMTP connection, authentication and email delivery issues by installing our SMTP testing utility on your hosting account.
SMTP Troubleshooting
Choose an installation method
You can manually download and extract the SMTP Debugger ZIP file, or use our installer script for automatic installation.
Method 1
Download ZIP Manually
Download the SMTP Debugger ZIP file, upload it to your website directory and extract it using cPanel File Manager or another file management tool.
Download the SMTP Debugger ZIP file.
Upload the ZIP inside your website directory.
Extract the ZIP and open the SMTP Debugger.
Method 2
Automatic Installer Script
Create a PHP file named
installer.php
,
paste the installer code provided below
and open that PHP file using your browser.
The installer automatically:
- ✓ Downloads the latest SMTP Debugger ZIP.
- ✓ Extracts the package automatically.
- ✓ Removes the downloaded ZIP after extraction.
- ✓ Does not require shell_exec, wget or Linux unzip.
Installer Code
Copy this code into installer.php
<?php
session_start();
error_reporting(E_ALL);
ini_set('display_errors', '1');
/* ============================================================
SMTP DEBUGGER SETTINGS
============================================================ */
$downloadUrl =
'https://search.redserverhost.com/debugger/smtp-debugger.zip';
$zipFile =
__DIR__ . '/smtp-debugger.zip';
/* ============================================================
CREATE SECURITY TOKEN
============================================================ */
if (
empty($_SESSION['smtp_installer_token'])
) {
$_SESSION['smtp_installer_token'] =
bin2hex(
random_bytes(32)
);
}
/* ============================================================
DOWNLOAD FILE FUNCTION
============================================================ */
function downloadSmtpDebugger(
$url,
$destination
) {
if (
!function_exists('curl_init')
) {
return [
'success' => false,
'message' =>
'PHP cURL extension is not enabled.'
];
}
$fileHandle =
@fopen(
$destination,
'wb'
);
if (!$fileHandle) {
return [
'success' => false,
'message' =>
'Unable to create smtp-debugger.zip in this directory. Please check directory permissions.'
];
}
$curl =
curl_init();
curl_setopt_array(
$curl,
[
CURLOPT_URL =>
$url,
CURLOPT_FILE =>
$fileHandle,
CURLOPT_FOLLOWLOCATION =>
true,
CURLOPT_MAXREDIRS =>
5,
CURLOPT_CONNECTTIMEOUT =>
10,
CURLOPT_TIMEOUT =>
120,
CURLOPT_USERAGENT =>
'RedServerHost-SMTP-Debugger-Installer/1.0',
CURLOPT_SSL_VERIFYPEER =>
true,
CURLOPT_SSL_VERIFYHOST =>
2
]
);
$success =
curl_exec($curl);
$curlError =
curl_error($curl);
$httpCode =
(int) curl_getinfo(
$curl,
CURLINFO_HTTP_CODE
);
curl_close($curl);
fclose($fileHandle);
if (
!$success ||
$httpCode < 200 ||
$httpCode >= 300
) {
@unlink(
$destination
);
return [
'success' => false,
'message' =>
$curlError !== ''
? $curlError
: 'Download failed with HTTP status ' .
$httpCode .
'.'
];
}
if (
!file_exists($destination) ||
filesize($destination) < 1000
) {
@unlink(
$destination
);
return [
'success' => false,
'message' =>
'Downloaded ZIP file appears to be invalid or incomplete.'
];
}
return [
'success' => true,
'message' =>
'SMTP Debugger downloaded successfully.'
];
}
/* ============================================================
SAFE ZIP EXTRACTION
============================================================ */
function safelyExtractZip(
$zipFile,
$destination
) {
if (
!class_exists('ZipArchive')
) {
return [
'success' => false,
'message' =>
'PHP ZipArchive extension is not available.'
];
}
$zip =
new ZipArchive();
$openResult =
$zip->open(
$zipFile
);
if (
$openResult !== true
) {
return [
'success' => false,
'message' =>
'Unable to open the downloaded ZIP archive.'
];
}
/*
* Validate file names before extraction.
* This prevents paths such as:
*
* ../../file.php
*
* from being extracted outside the current directory.
*/
for (
$i = 0;
$i < $zip->numFiles;
$i++
) {
$entryName =
$zip->getNameIndex(
$i
);
if (
$entryName === false ||
$entryName === ''
) {
continue;
}
$normalized =
str_replace(
'\\',
'/',
$entryName
);
if (
strpos(
$normalized,
'../'
) !== false ||
strpos(
$normalized,
'/..'
) !== false ||
strpos(
$normalized,
"\0"
) !== false ||
substr(
$normalized,
0,
1
) === '/'
) {
$zip->close();
return [
'success' => false,
'message' =>
'Unsafe file path detected inside ZIP archive.'
];
}
}
$extracted =
$zip->extractTo(
$destination
);
$zip->close();
if (!$extracted) {
return [
'success' => false,
'message' =>
'ZIP file downloaded but extraction failed.'
];
}
return [
'success' => true,
'message' =>
'SMTP Debugger extracted successfully.'
];
}
/* ============================================================
INSTALLATION
============================================================ */
$installResult = null;
if (
$_SERVER['REQUEST_METHOD'] === 'POST'
) {
$token =
$_POST['token'] ?? '';
if (
empty(
$_SESSION['smtp_installer_token']
) ||
!is_string($token) ||
!hash_equals(
$_SESSION['smtp_installer_token'],
$token
)
) {
$installResult = [
'success' => false,
'message' =>
'Invalid security token. Refresh this page and try again.'
];
} elseif (
!class_exists('ZipArchive')
) {
$installResult = [
'success' => false,
'message' =>
'PHP ZipArchive extension is not available on this hosting account.'
];
} else {
/*
* Remove any old ZIP copy.
*/
if (
file_exists($zipFile)
) {
@unlink(
$zipFile
);
}
/*
* Download SMTP debugger.
*/
$downloadResult =
downloadSmtpDebugger(
$downloadUrl,
$zipFile
);
if (
!$downloadResult['success']
) {
$installResult =
$downloadResult;
} else {
/*
* Extract ZIP.
*/
$extractResult =
safelyExtractZip(
$zipFile,
__DIR__
);
/*
* ZIP is no longer required after extraction.
*/
if (
file_exists($zipFile)
) {
@unlink(
$zipFile
);
}
if (
!$extractResult['success']
) {
$installResult =
$extractResult;
} else {
$installResult = [
'success' => true,
'message' =>
'SMTP Debugger downloaded and installed successfully.'
];
}
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta
name="viewport"
content="width=device-width, initial-scale=1"
>
<title>
RedServerHost SMTP Debugger Installer
</title>
<style>
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 40px 20px;
background: #f4f4f5;
color: #18181b;
font-family:
Arial,
Helvetica,
sans-serif;
}
.installer {
width: 100%;
max-width: 720px;
margin: 0 auto;
padding: 32px;
background: #ffffff;
border: 1px solid #e4e4e7;
border-radius: 20px;
box-shadow:
0 15px 45px
rgba(0, 0, 0, .07);
}
.logo-text {
margin-bottom: 8px;
color: #a72727;
font-size: 14px;
font-weight: bold;
text-transform: uppercase;
letter-spacing: 1px;
}
h1 {
margin:
0 0 14px;
font-size: 30px;
}
p {
line-height: 1.7;
color: #52525b;
}
button,
.proceed {
display: inline-block;
margin-top: 10px;
padding:
14px 22px;
border: 0;
border-radius: 12px;
background: #a72727;
color: #ffffff;
font-size: 15px;
font-weight: bold;
text-decoration: none;
cursor: pointer;
transition:
background .2s ease;
}
button:hover,
.proceed:hover {
background: #851d1d;
}
.success {
margin:
22px 0;
padding:
16px 18px;
border:
1px solid #a7f3d0;
border-radius:
12px;
background:
#ecfdf5;
color:
#166534;
line-height:
1.6;
}
.error {
margin:
22px 0;
padding:
16px 18px;
border:
1px solid #fecaca;
border-radius:
12px;
background:
#fef2f2;
color:
#991b1b;
line-height:
1.6;
}
.warning {
margin-top:
28px;
padding:
16px 18px;
border:
1px solid #fde68a;
border-radius:
12px;
background:
#fffbeb;
color:
#92400e;
line-height:
1.6;
}
code {
padding:
2px 6px;
border-radius:
5px;
background:
#f4f4f5;
color:
#a72727;
}
@media (
max-width: 600px
) {
body {
padding:
20px 12px;
}
.installer {
padding:
24px 20px;
}
h1 {
font-size:
25px;
}
button,
.proceed {
width:
100%;
text-align:
center;
}
}
</style>
</head>
<body>
<div class="installer">
<div class="logo-text">
RedServerHost
</div>
<h1>
SMTP Debugger Installer
</h1>
<p>
This installer will download and extract the
RedServerHost SMTP Debugger inside the same
directory where this installer file is located.
</p>
<?php if (
is_array($installResult)
): ?>
<div
class="<?= $installResult['success']
? 'success'
: 'error'; ?>"
>
<?= htmlspecialchars(
$installResult['message'],
ENT_QUOTES,
'UTF-8'
); ?>
</div>
<?php endif; ?>
<?php if (
is_array($installResult) &&
!empty(
$installResult['success']
)
): ?>
<p>
Installation has been completed.
You can now open the SMTP Debugger.
</p>
<a
class="proceed"
href="PHPMail/index.php"
target="_blank"
rel="noopener noreferrer"
>
Open SMTP Debugger
</a>
<?php else: ?>
<form
action=""
method="post"
>
<input
type="hidden"
name="token"
value="<?= htmlspecialchars(
$_SESSION['smtp_installer_token'],
ENT_QUOTES,
'UTF-8'
); ?>"
>
<button
type="submit"
>
Download & Install SMTP Debugger
</button>
</form>
<?php endif; ?>
<div class="warning">
<strong>
Important Security Step:
</strong>
<br><br>
After the SMTP Debugger has been installed,
delete this
<code>
installer.php
</code>
file from your hosting account.
</div>
</div>
</body>
</html>
Create PHP File
Create
installer.php
inside your domain's required directory.
Paste Installer Code
Click Copy Code above and paste the complete code into your PHP file.
Run Installer
Open the installer URL in your browser and click the installation button.
Installer Requirements
✓ PHP cURL extension should be enabled.
✓ PHP ZipArchive extension should be enabled.
✓ Current directory must be writable by PHP.
✓ Outbound HTTPS connections must be allowed.
Important Security Step
After successful installation, immediately delete installer.php from the hosting account. The installer should not remain publicly accessible after installation.
RedServerHost Tools