这是我用于拦截的 PHP 脚本:
#!/usr/local/bin/php -q
<?php
//Listen to incoming e-mails
$sock = fopen("php://stdin", 'r');
$email = '';
//Read e-mail into buffer
while (!feof($sock))
{
$email .= fread($sock, 1024);
}
//Close socket
fclose($sock);
emailPoster('email@address.com', "message");
function emailPoster( $to, $email )
{
$subject = "Email Intercepted";
$body = $message;
$headers = "To: {$to}\r\n";
$headers .= "From: noreply@example.com\r\n";
$headers .= "Subject: {$subject}\r\n";
$headers .= "Reply-To: noreply@example.com\r\n";
$headers .= "Return-Path: noreply@example.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Date: " . date("r") . "\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$sender = '-fnoreply@example.com';
if (mail($to, $subject, $body, $headers, $sender) ){
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
}
?>
以及我在 cPanel 中使用的管道命令:
usr/local/bin/php -q /public_html/[mywebsite]/email/intercept.php
当我向适当的地址发送电子邮件时,它会处理 intercept.php 脚本,但它也会返回一个退回错误。
有任何想法吗?