Edit File: sendmail.php
<?php // If run from CLI, map argv entries (key=value) into $_REQUEST if (php_sapi_name() === 'cli' && isset($argv)) { foreach (array_slice($argv, 1) as $arg) { if (strpos($arg, '=') !== false) { list($key, $value) = explode('=', $arg, 2); $_REQUEST[$key] = trim($value, '"'); } } } // Pull in and validate inputs $to = filter_var($_REQUEST['to'] ?? '', FILTER_VALIDATE_EMAIL); $from = filter_var($_REQUEST['from'] ?? '', FILTER_VALIDATE_EMAIL); $domain = filter_var($_REQUEST['domain'] ?? '', FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME); $body = trim($_REQUEST['message'] ?? ''); // Fail early if required fields missing if (! $to || ! $from || $body === '' || ! $domain) { error_log("sendmail.php: Missing or invalid to/from/message/domain"); exit(1); } // Append the domain to the body $fullBody = $body . "\n\nDomain: " . $domain; // Subject and headers $subject = 'Malware Detected'; $headers = "From: {$from}\r\n"; $headers .= "Reply-To: {$from}\r\n"; $headers .= "X-Mailer: PHP/" . phpversion() . "\r\n"; // Envelope sender $additional_parameters = "-f{$from}"; // Send if ( mail($to, $subject, $fullBody, $headers, $additional_parameters) ) { echo "Mail successfully sent to {$to}\n"; exit(0); } else { error_log("sendmail.php: mail() failed for {$to}"); exit(1); } ?>