1

インターセプトに使用する 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 スクリプトは処理されますが、バウンスバック エラーも返されます。

何か案は?

4

3 に答える 3

4

電子メールを php スクリプトにパイプする場合、スクリプトで「ECHO」またはその他の出力コマンドを使用することはできません。すべての出力コマンドがエラーになります。また、ファイルの末尾から「?>」を削除します。このタグの後のすべての文字は出力ヘッダーを作成し、エラーを引き起こします。

于 2013-09-15T07:04:03.873 に答える
0

あなたはいつでも置くことができます:

return NULL;

PHP ファイルの最後で、スクリプトのバウンスを停止するすべてのリターン メッセージを停止します。

于 2015-07-22T15:32:51.593 に答える