私はこれを熱心に研究しました。ここで、Stack Overflow で、配信不能なメールを跳ね返したい場合は、php の mail() 関数で -f パラメータを使用する必要があることを発見しました。以下は私のスクリプトです(現在の状態):
//Send Confirmation email. Following are the variables for the email
// mail function best practices: http://collaborate.extension.org/wiki/Best_Practices_Using_the_PHP_mail_Function
$sendto = $email; // this is the email address collected from the foreach routine.
$e_subject = stripslashes($subject); // Subject
//$message = "<html>" . stripslashes($body) . "</html>";
$message = "
<html>
<body>
<p>Hello " . stripslashes($fName) . ":</p>
<div>" . stripslashes($body) . "</div>
</body>
</html>
";
// Always set content-type when sending HTML email
$header = "MIME-Version: 1.0" . "\r\n";
$header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";;
// extract user domain so you can set up X-Mailer
$u_domain=substr(strrchr($user_email, '@'), 1);
$dom_array = explode(".",$u_domain);
$user_domain = $dom_array[0];
$header .= "X-Mailer: ". $user_domain ."\r\n";
$header .= "X-Sender-IP: {$_SERVER['REMOTE_ADDR']}\r\n";
$header .= "X-Originating-IP: [".getenv("REMOTE_ADDR")."]\r\n";
$header .= "From: " . $user_email . "\r\n";
$header .= "Sender: ". $user_email . "\r\n";
// The "envelope sender" is the address listed in the "Return-Path:" header - and controls where the email is sent to in the event that a recipient address bounces. http://collaborate.extension.org/wiki/Best_Practices_Using_the_PHP_mail_Function
$header .= "Return-Path:" . $user_email . "\r\n";
$header .= "Reply-To:" . $user_email . "\r\n";
$bounceTo = "-f". $user_email;
// Collect variables from above and insert into the mail() function.
mail($sendto, $e_subject, $message, $header,$bounceTo);
多くのコメントがあることに気付くでしょう - 私はこれを理解しようとしているだけです. 私の mail() は素晴らしく送信します。メールは、本来あるべき書式で受信トレイに届きます。しかし... $bounceTo 変数 ("-f" . $user_email) が機能していません。3 つの非アクティブなアドレスに意図的にメールを送信しましたが、返送がありません。
バウンス バックに影響する可能性があることを知ったので、上記のコードのすべてのヘッダー設定が適切です。不必要なヘッダーを取り除き、必要なものを追加したいと思っています。しかし... この時点で、スクリプトは混乱しているように見えます-バウンスバックを生成していません.
どんな提案でも大歓迎です。
どうもありがとう:
パビリオン