File: /home/ocwno/public_html/.0/fly.php
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Retrieve form data
$recipients = explode("\n", trim($_POST['recipients']));
$senderName = trim($_POST['sender_name']);
$senderEmail = trim($_POST['sender_email']);
$subject = trim($_POST['subject']);
$message = $_POST['message'];
// Ensure UTF-8 encoding for the message
$message = mb_convert_encoding($message, 'UTF-8', 'auto');
// Encode the sender's name and subject to support UTF-8 characters
$encodedSenderName = '=?UTF-8?B?' . base64_encode($senderName) . '?=';
$encodedSubject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
// Set email headers
$headers = "From: $encodedSenderName <$senderEmail>\r\n";
$headers .= "Reply-To: $senderEmail\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
// Initialize success and failure counters
$successCount = 0;
$failureCount = 0;
// Define the batch size
$batchSize = 100;
$totalRecipients = count($recipients);
// Process emails in batches
for ($i = 0; $i < $totalRecipients; $i += $batchSize) {
$batch = array_slice($recipients, $i, $batchSize);
foreach ($batch as $to) {
$to = trim($to); // Clean up any extra whitespace
if (!empty($to)) {
if (mail($to, $encodedSubject, $message, $headers)) {
$successCount++;
} else {
$failureCount++;
}
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Email Results</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
.result { padding: 20px; border: 1px solid #ddd; background-color: #f9f9f9; }
.success { color: green; }
.failure { color: red; }
</style>
</head>
<body>
<div class="result">
<?php if ($successCount > 0): ?>
<p class="success"><?php echo $successCount; ?> email(s) sent successfully!</p>
<?php endif; ?>
<?php if ($failureCount > 0): ?>
<p class="failure"><?php echo $failureCount; ?> email(s) failed to send.</p>
<?php endif; ?>
<a href="fly-100.php">Go Back</a>
</div>
</body>
</html>
<?php
} else {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Email Sender</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
form { max-width: 600px; margin: auto; }
label { display: block; margin-bottom: 5px; }
input, textarea { width: 100%; margin-bottom: 10px; padding: 8px; box-sizing: border-box; }
textarea { height: 200px; }
button { padding: 10px 20px; background-color: #007bff; color: #fff; border: none; cursor: pointer; }
button:hover { background-color: #0056b3; }
</style>
</head>
<body>
<h1>Send HTML Emails</h1>
<form action="" method="post">
<label for="recipients">Mailing List (one email per line):</label>
<textarea id="recipients" name="recipients" required></textarea>
<label for="sender_name">Sender Name:</label>
<input type="text" id="sender_name" name="sender_name" required>
<label for="sender_email">Sender Email:</label>
<input type="email" id="sender_email" name="sender_email" required>
<label for="subject">Subject:</label>
<input type="text" id="subject" name="subject" required>
<label for="message">HTML Message:</label>
<textarea id="message" name="message" required></textarea>
<button type="submit">Send Email</button>
</form>
</body>
</html>
<?php
}
?>