From 99592315c93c60e251a6c0ff57721afd03c08b85 Mon Sep 17 00:00:00 2001
From: Gab <24553253+gabrix73@users.noreply.github.com>
Date: Wed, 21 May 2025 15:18:19 +0200
Subject: Create send_email_with_tor.php
---
send_email_with_tor.php | 229 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 229 insertions(+)
create mode 100644 send_email_with_tor.php
diff --git a/send_email_with_tor.php b/send_email_with_tor.php
new file mode 100644
index 0000000..c52de23
--- /dev/null
+++ b/send_email_with_tor.php
@@ -0,0 +1,229 @@
+ 3) {
+ $errors[] = "Number of copies must be between 1 and 3";
+ }
+
+ // Check if Tor is available
+ if (!isTorAvailable()) {
+ $errors[] = "Tor is required but not available on the system. Please install and start Tor service.";
+ }
+
+ // If no errors, proceed with sending
+ if (empty($errors)) {
+ // Build the remailer chain
+ $chain = "$entryRemailer,$middleRemailer,$exitRemailer";
+
+ // Build headers
+ $headers = "Content-Type: text/plain; charset=utf-8\n";
+ $headers .= "Content-Transfer-Encoding: 8bit\n";
+ $headers .= "MIME-Version: 1.0\n";
+
+ if (!empty($references)) {
+ $headers .= "References: $references\n";
+ }
+
+ // Build message content
+ $messageContent = $headers . "From: $from\n";
+
+ if (!empty($replyTo)) {
+ $messageContent .= "Reply-To: $replyTo\n";
+ }
+
+ $messageContent .= "To: $to\nSubject: $subject\n";
+
+ if (!empty($newsgroups)) {
+ $messageContent .= "Newsgroups: $newsgroups\n";
+ }
+
+ $messageContent .= "\n$data";
+
+ // Create a unique filename for the message
+ $messageFile = '/var/www/yamnweb/message_' . time() . '_' . rand(1000, 9999) . '.txt';
+
+ $write_success = file_put_contents($messageFile, $messageContent);
+ if ($write_success === false) {
+ echo "Error: Unable to write to message file. Check permissions.";
+ exit;
+ }
+
+ // Log the operation
+ $log_entry = date('Y-m-d H:i:s') . " - Sending message: from $from to $to using Tor\n";
+ file_put_contents('/var/www/yamnweb/send_log.txt', $log_entry, FILE_APPEND);
+
+ // Send the email with Tor (always enabled)
+ try {
+ $result = sendYamnEmail($chain, $copies, $messageFile, $useTor);
+ } catch (Exception $e) {
+ echo "Error sending email: " . $e->getMessage();
+ exit;
+ }
+
+ // Clean up message file after sending
+ if (file_exists($messageFile)) {
+ unlink($messageFile);
+ }
+
+ // Display result to user
+ if ($result['success']) {
+ echo "
+
+
+
+
+ Email Sent - YAMN Web Interface
+
+
+
+
+
Email sent successfully!
+
Your email has been added to the YAMN sending queue.
+
As per system policy, Tor was used for enhanced anonymity.
+
Return to Home
+
+
+ ";
+ } else {
+ echo "
+
+
+
+
+ Email Error - YAMN Web Interface
+
+
+
+
+
+
Error sending email
+
An error occurred while processing your request.
+
Error details:
+
";
+ echo "===== ADD TO POOL COMMAND =====\n";
+ echo htmlspecialchars($result['add_to_pool']['command']) . "\n\n";
+ echo "===== ADD TO POOL OUTPUT =====\n";
+ echo htmlspecialchars(implode("\n", $result['add_to_pool']['output'])) . "\n\n";
+ echo "===== ADD TO POOL RETURN CODE =====\n";
+ echo $result['add_to_pool']['return_var'] . "\n\n";
+
+ if (isset($result['send']) && $result['add_to_pool']['return_var'] == 0) {
+ echo "===== SEND COMMAND =====\n";
+ echo htmlspecialchars($result['send']['command']) . "\n\n";
+ echo "===== SEND OUTPUT =====\n";
+ echo htmlspecialchars(implode("\n", $result['send']['output'])) . "\n\n";
+ echo "===== SEND RETURN CODE =====\n";
+ echo $result['send']['return_var'] . "\n";
+ }
+ echo "
+
Please check system logs for more details.
+
Return to Home
+
+
+ ";
+
+ // Detailed error logging
+ $logEntry = "==== ERROR LOG ====\n";
+ $logEntry .= "Date: " . date('Y-m-d H:i:s') . "\n";
+ $logEntry .= "From: $from\n";
+ $logEntry .= "To: $to\n";
+ $logEntry .= "Subject: $subject\n";
+ if (!empty($newsgroups)) {
+ $logEntry .= "Newsgroups: $newsgroups\n";
+ }
+ $logEntry .= "Chain: $chain\n";
+ $logEntry .= "Copies: $copies\n";
+ $logEntry .= "Using Tor: Yes\n";
+ $logEntry .= "\n=== ADD TO POOL ===\n";
+ $logEntry .= "Command: " . $result['add_to_pool']['command'] . "\n";
+ $logEntry .= "Output: " . implode("\n", $result['add_to_pool']['output']) . "\n";
+ $logEntry .= "Return Code: " . $result['add_to_pool']['return_var'] . "\n";
+
+ if (isset($result['send'])) {
+ $logEntry .= "\n=== SEND ===\n";
+ $logEntry .= "Command: " . $result['send']['command'] . "\n";
+ $logEntry .= "Output: " . implode("\n", $result['send']['output']) . "\n";
+ $logEntry .= "Return Code: " . $result['send']['return_var'] . "\n";
+ }
+
+ $logEntry .= "----------------------------------------\n";
+ error_log($logEntry, 3, "/var/www/yamnweb/email_errors.log");
+ }
+ } else {
+ // Display validation errors
+ echo "
+
+
+
+
+ Form Error - YAMN Web Interface
+
+
+
+
+
Form Errors
+
";
+ foreach ($errors as $error) {
+ echo "- " . htmlspecialchars($error) . "
";
+ }
+ echo "
+
Back to Form
+
+
+ ";
+ }
+} else {
+ // If not a POST request, redirect to home
+ header("Location: index.php");
+ exit;
+}
+?>
--
cgit v1.2.3