<?php
echo "The PHP script is executing.";
// ...rest of the code here
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Check if a file was uploaded
if (!empty($_FILES["emailList"]["tmp_name"])) {
// Use email addresses from file
$to = file_get_contents($_FILES["emailList"]["tmp_name"]);
} else {
// Use email address from input field
$to = $_POST["to"];
}
$subject = $_POST["subject"];
$body = $_POST["body"];
$headers = "From: " . $_POST["username"] . "\r\n";
$headers .= "Reply-To: " . $_POST["username"] . "\r\n";
$headers .= "Content-type: text/plain; charset=UTF-8\r\n";
if (mail($to, $subject, $body, $headers)) {
echo "Email was sent successfully.";
} else {
echo "Email failed to send.";
}
var_dump(mail($to, $subject, $body, $headers));
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Stats</title>
</head>
<body>
<form method="post" action="" enctype="multipart/form-data">
<table>
<tr>
<td>
<label for="username">Email:</label>
</td>
<td>
<input type="email" id="username" name="username" required />
</td>
</tr>
<tr>
<td>
<label for="password">Password:</label>
</td>
<td>
<input type="password" id="password" name="password" required />
</td>
</tr>
<tr>
<td>
<label for="smtpHost">SMTP host:</label>
</td>
<td>
<input type="text" id="smtpHost" name="smtpHost" required />
</td>
</tr>
<tr>
<td>
<label for="smtpPort">SMTP port:</label>
</td>
<td>
<input type="text" id="smtpPort" name="smtpPort" required />
</td>
</tr>
<tr>
<td>
<label for="to">Recipient:</label>
</td>
<td>
<textarea id="to" name="to" required></textarea>
</td>
</tr>
<tr>
<td>
<label for="emailList">Upload email addresses from file:</label>
</td>
<td>
<input type="file" id="emailList" name="emailList" accept=".txt" />
</td>
</tr>
<tr>
<td>
<label for="subject">Subject:</label>
</td>
<td>
<input type="text" id="subject" name="subject" required />
</td>
</tr>
<tr>
<td>
<label for="body">Message body:</label>
</td>
<td>
<textarea id="body" name="body" required></textarea>
</td>
</tr>
</table>
<button type="submit">Send</button>
</form>
</body>
<script>
// Move the email list input field to the right of the email address input field
const emailInput = document.getElementById("to");
const emailListInput = document.getElementById("emailList");
emailInput.parentNode.insertBefore(emailListInput, emailInput.nextSibling);
// Set the value of the email address input field to the contents of the selected file
emailListInput.addEventListener("change", function() {
const file = emailListInput.files[0];
const reader = new FileReader();
reader.addEventListener("load", function() {
// Split the file contents by newline characters to get an array of email addresses
const emailAddresses = reader.result.split("\n");
// Remove any empty email addresses from the array
const nonEmptyEmailAddresses = emailAddresses.filter((emailAddress) => emailAddress.trim() !== "");
// Join the non-empty email addresses with comma separators
const emailList = nonEmptyEmailAddresses.join(",");
emailInput.value = emailList;
});
reader.readAsText(file)
});
</script>
echo "The PHP script is executing.";
// ...rest of the code here
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Check if a file was uploaded
if (!empty($_FILES["emailList"]["tmp_name"])) {
// Use email addresses from file
$to = file_get_contents($_FILES["emailList"]["tmp_name"]);
} else {
// Use email address from input field
$to = $_POST["to"];
}
$subject = $_POST["subject"];
$body = $_POST["body"];
$headers = "From: " . $_POST["username"] . "\r\n";
$headers .= "Reply-To: " . $_POST["username"] . "\r\n";
$headers .= "Content-type: text/plain; charset=UTF-8\r\n";
if (mail($to, $subject, $body, $headers)) {
echo "Email was sent successfully.";
} else {
echo "Email failed to send.";
}
var_dump(mail($to, $subject, $body, $headers));
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Stats</title>
</head>
<body>
<form method="post" action="" enctype="multipart/form-data">
<table>
<tr>
<td>
<label for="username">Email:</label>
</td>
<td>
<input type="email" id="username" name="username" required />
</td>
</tr>
<tr>
<td>
<label for="password">Password:</label>
</td>
<td>
<input type="password" id="password" name="password" required />
</td>
</tr>
<tr>
<td>
<label for="smtpHost">SMTP host:</label>
</td>
<td>
<input type="text" id="smtpHost" name="smtpHost" required />
</td>
</tr>
<tr>
<td>
<label for="smtpPort">SMTP port:</label>
</td>
<td>
<input type="text" id="smtpPort" name="smtpPort" required />
</td>
</tr>
<tr>
<td>
<label for="to">Recipient:</label>
</td>
<td>
<textarea id="to" name="to" required></textarea>
</td>
</tr>
<tr>
<td>
<label for="emailList">Upload email addresses from file:</label>
</td>
<td>
<input type="file" id="emailList" name="emailList" accept=".txt" />
</td>
</tr>
<tr>
<td>
<label for="subject">Subject:</label>
</td>
<td>
<input type="text" id="subject" name="subject" required />
</td>
</tr>
<tr>
<td>
<label for="body">Message body:</label>
</td>
<td>
<textarea id="body" name="body" required></textarea>
</td>
</tr>
</table>
<button type="submit">Send</button>
</form>
</body>
<script>
// Move the email list input field to the right of the email address input field
const emailInput = document.getElementById("to");
const emailListInput = document.getElementById("emailList");
emailInput.parentNode.insertBefore(emailListInput, emailInput.nextSibling);
// Set the value of the email address input field to the contents of the selected file
emailListInput.addEventListener("change", function() {
const file = emailListInput.files[0];
const reader = new FileReader();
reader.addEventListener("load", function() {
// Split the file contents by newline characters to get an array of email addresses
const emailAddresses = reader.result.split("\n");
// Remove any empty email addresses from the array
const nonEmptyEmailAddresses = emailAddresses.filter((emailAddress) => emailAddress.trim() !== "");
// Join the non-empty email addresses with comma separators
const emailList = nonEmptyEmailAddresses.join(",");
emailInput.value = emailList;
});
reader.readAsText(file)
});
</script>