From f337c5701bc96e928767762bd939591c3c8ab10d Mon Sep 17 00:00:00 2001
From: Gab <24553253+gabrix73@users.noreply.github.com>
Date: Tue, 31 Dec 2024 04:25:18 +0100
Subject: Create send_email.php
---
send_email.php | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 77 insertions(+)
create mode 100644 send_email.php
diff --git a/send_email.php b/send_email.php
new file mode 100644
index 0000000..1927491
--- /dev/null
+++ b/send_email.php
@@ -0,0 +1,77 @@
+ 3) {
+ error_log("Error: Number of copies must be between 1 and 3.", 3, "/var/www/yamnweb/email_log.txt");
+ echo "Error: Number of copies must be between 1 and 3.";
+ exit;
+ }
+
+ $chain = "$entryRemailer,$middleRemailer,$exitRemailer";
+ $headers = "X-User-Agent: Victor's Yamn Web Interface\n";
+ $headers .= "X-Mailer: Victor Hostile Communications Center\n";
+ $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";
+ }
+ $messageContent = $headers . "From: $from\nTo: $to\nSubject: $subject\n";
+ if (!empty($newsgroups)) {
+ $messageContent .= "Newsgroups: $newsgroups\n";
+ }
+ $messageContent .= "\n$data";
+ file_put_contents('/var/www/yamnweb/message.txt', $messageContent);
+
+ // Aggiungi la mail al pool
+ $command_add_to_pool = "/opt/yamn-master/yamn --config=/opt/yamn-master/yamn.yml --mail --chain=\"$chain\" --copies=$copies < /var/www/yamnweb/message.txt";
+ exec($command_add_to_pool, $output_add_to_pool, $return_var_add_to_pool);
+
+ // Invia le mail presenti nel pool
+ $command_send = "/opt/yamn-master/yamn --config=/opt/yamn-master/yamn.yml -S";
+ exec($command_send, $output_send, $return_var_send);
+
+ // Log dei dettagli dell'invio
+ if ($return_var_send != 0) {
+ $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";
+ }
+ if (!empty($references)) {
+ $logEntry .= "References: $references\n";
+ }
+ $logEntry .= "Chain: $chain\n";
+ $logEntry .= "Copies: $copies\n";
+ $logEntry .= "Command Add to Pool: $command_add_to_pool\n";
+ $logEntry .= "Output Add to Pool: " . implode("\n", $output_add_to_pool) . "\n";
+ $logEntry .= "Return Code Add to Pool: $return_var_add_to_pool\n";
+ $logEntry .= "Command Send: $command_send\n";
+ $logEntry .= "Output Send: " . implode("\n", $output_send) . "\n";
+ $logEntry .= "Return Code Send: $return_var_send\n";
+ $logEntry .= "----------------------------------------\n";
+
+ error_log($logEntry, 3, "/var/www/yamnweb/email_log.txt");
+ }
+
+ if ($return_var_send == 0) {
+ echo "Email sent successfully!
";
+ echo "Return to Home";
+ } else {
+ echo "Error sending email.";
+ }
+}
+?>
--
cgit v1.2.3