1

PHPの関数mail()でメールを送信する必要があります。Reply-Toヘッダーを挿入する必要がありますが、機能しません。

<?php
    $body = "<html>\n";
    $body .= "<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif; font-size:12px; color:#666666;\">\n";
    $body = $message;
    $body .= "</body>\n";
    $body .= "</html>\n";

    $headers  = "From: My site<noreply@example.com>\r\n";
    $headers .= "Reply-To: info@example.com\r\n";
    $headers .= "Return-Path: info@example.com\r\n";
    $headers .= "X-Mailer: Drupal\n";
    $headers .= 'MIME-Version: 1.0' . "\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

    return mail($recipient, $subject, $message, $headers); ?>

このphp.netの例には、$headers。="Reply-To:info@example.com \ r\n";があります。ただし、これをコピーして貼り付けてからメールを送信する場合、Reply-Toヘッダーはありません。From、CC、Bccなどの他のヘッダーを挿入すると、これらはHTMLメールに正しく含まれますが、Reply-Toヘッダーのみは含まれません。「Reply-to」、「Reply to」、「Reply To」、「Reply」などを試しましたが、うまくいきません。私はPhp5.4を使用していますが、役に立ちますか?

4

1 に答える 1

3

これを試して。

受信者、件名、およびメッセージのパラメーターを追加します。

次に、この行で " return mail($recipient, $subject, $message, $headers); "

$message を $body に置き換えます。

こんな風に見える

<?php

$recipient = "jack@example.com";
$subject = "test subject";
$message = "test message";
$body = "<html>\n";
$body .= "<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif; font-size:12px; color:#666666;\">\n";
$body = $message;
$body .= "</body>\n";
$body .= "</html>\n";

$headers  = "From: My site<noreply@example.com>\r\n";
$headers .= "Reply-To: info@example.com\r\n";
$headers .= "Return-Path: info@example.com\r\n";
$headers .= "X-Mailer: Drupal\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$result = mail($recipient, $subject, $body, $headers); 
var_dump($result);

?>

それがあなたを助けることを願っています

于 2012-07-23T10:40:33.883 に答える