Ich habe das folgende Stück Code geschrieben, um einen im E-Mail-Stream bestehenden E-Mail-Stream zu lesen (oder .Eml-Datei während des Testens). PrettyPrint-Override ">
function sendMailForward($email) {
// Load recipients from ENV (comma-separated list)
$newRecipients = preg_split("/,\s*/", $_ENV['ADMIN_EMAIL'] ?? '', -1, PREG_SPLIT_NO_EMPTY);
// For StackOverflow: This passes in a comma-separated list of emails, this line is not part of the problem.
$raw_email = "";
while (!feof($email)) {
$raw_email .= fread($email, 1024);
}
fclose($email);
// Extract headers for a clean subject and sender
$headers = [];
$lines = explode("\n", $raw_email); // This line, somehow, doesn't see newlines in the stream.
foreach ($lines as $line) {
echo "New line!\n"; // This was me trying to test and what should show up multiple times, only shows up once.
if (strpos($line, ":") !== false) {
$parts = explode(":", $line, 2);
$key = trim($parts[0]);
$value = trim($parts[1]);
$headers[$key] = $value;
}
// Stop at the first blank line, which marks the end of headers
if (trim($line) == "") {
break;
}
}
$original_subject = isset($headers['Subject']) ? "FWD: " . $headers['Subject'] : "FWD: No Subject";
$original_from = isset($headers['From']) ? $headers['From'] : "unknown sender";
$subject = $original_subject;
$message = "--- Original message from $original_from ---\n\n" . $raw_email;
$extra_headers = "From: [email protected]\r\n"; // Customize 'From' address
foreach ($newRecipients as $recipient) {
$to = $recipient;
// Send the email
mail($to, $subject, $message, $extra_headers);
}
}
< /code>
Was soll ich im obigen Code ändern? Sollte ich eine neue Linie erzwingen, um anzuhängen? Oder gibt es noch etwas, das mir bewusst sein sollte. Dies ist die E-Mail, die ich zum Testen verwenden kann.
From: "Megan at TCGplayer"
To: "TCGPlayer Account"
Subject: Test Email for Forwarding
Date: Sat, 28 Sep 2025 08:00:00 -0400
Message-ID:
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
Hello,
This is a test email to verify the mail forwarding module.
Best regards,
Test System
< /code>
Bearbeiten 2: Jemand hat nach dem verwendeten Code gefragt.// Read original message from stdin
$rawEmail = file_get_contents('php://stdin');
sendMailForward($rawEmail);
Ich habe das folgende Stück Code geschrieben, um einen im E-Mail-Stream bestehenden E-Mail-Stream zu lesen (oder .Eml-Datei während des Testens). PrettyPrint-Override ">[code]function sendMailForward($email) { // Load recipients from ENV (comma-separated list) $newRecipients = preg_split("/,\s*/", $_ENV['ADMIN_EMAIL'] ?? '', -1, PREG_SPLIT_NO_EMPTY);
// For StackOverflow: This passes in a comma-separated list of emails, this line is not part of the problem.
// Extract headers for a clean subject and sender $headers = []; $lines = explode("\n", $raw_email); // This line, somehow, doesn't see newlines in the stream. foreach ($lines as $line) { echo "New line!\n"; // This was me trying to test and what should show up multiple times, only shows up once. if (strpos($line, ":") !== false) { $parts = explode(":", $line, 2); $key = trim($parts[0]); $value = trim($parts[1]); $headers[$key] = $value; } // Stop at the first blank line, which marks the end of headers if (trim($line) == "") { break; } }
foreach ($newRecipients as $recipient) { $to = $recipient; // Send the email mail($to, $subject, $message, $extra_headers); } }
< /code> Was soll ich im obigen Code ändern? Sollte ich eine neue Linie erzwingen, um anzuhängen? Oder gibt es noch etwas, das mir bewusst sein sollte. Dies ist die E-Mail, die ich zum Testen verwenden kann. From: "Megan at TCGplayer" To: "TCGPlayer Account" Subject: Test Email for Forwarding Date: Sat, 28 Sep 2025 08:00:00 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit
Hello,
This is a test email to verify the mail forwarding module.
Best regards, Test System < /code> Bearbeiten 2: Jemand hat nach dem verwendeten Code gefragt.// Read original message from stdin $rawEmail = file_get_contents('php://stdin');
sendMailForward($rawEmail); [/code] Stellen Sie es einfach auf, es nur aufzurufen.
Ich möchte ein Python -Programm auf einer lokalen Maschine durchführen, die nicht sicher ist, und im Idealfall möchte ich, dass dieses Python -Programm nie alle gleichzeitig im lokalen Speicher...
Ich bin neu, indem ich Label Studio verwende und ich bin zugewiesen, ein Projekt zum Extrahieren von Daten aus Rechnungen mit verschiedenen Layouts mit Layoutlm zu erstellen. Um jedes Wort mit O zu...
Ich habe eine Website, auf der Benutzer eine einfache Beschreibung des kurzen Profils schreiben müssen. Einige Benutzer schreiben hässliche Profile mit einer Reihe leerer Räume und überschüssigen...