\r\n"); $response = $readResponse($smtp); $log[] = "FROM: $response"; // RCPT TO fputs($smtp, "RCPT TO: <$to>\r\n"); $response = $readResponse($smtp); $log[] = "TO: $response"; // DATA fputs($smtp, "DATA\r\n"); $response = $readResponse($smtp); $log[] = "DATA: $response"; // Headers i treść $headers = "From: " . $config['from_name'] . " <" . $config['from_email'] . ">\r\n"; $headers .= "To: <$to>\r\n"; $headers .= "Subject: =?UTF-8?B?" . base64_encode($subject) . "?=\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; $headers .= "\r\n"; fputs($smtp, $headers . $html_body . "\r\n.\r\n"); $response = $readResponse($smtp); $log[] = "SEND: $response"; // QUIT fputs($smtp, "QUIT\r\n"); $response = $readResponse($smtp); $log[] = "QUIT: $response"; fclose($smtp); $success = strpos($response, '250') !== false || strpos($response, '221') !== false; $log[] = "Result: " . ($success ? "SUCCESS" : "FAILED"); file_put_contents($log_file, implode("\n", $log) . "\n\n", FILE_APPEND); return $success; }