doutang1946 2018-01-24 17:33
浏览 75
已采纳

将$ _POST变量分配给PHP Mailer()参数

How can one assign $_POST variables to the PHP mailer() 'From:' header parameter?

Here's what I tried:

$toEmail="email@example.com";
$formSubject=$_POST["esubject"];
$formComment=$_POST["comment"];
$header= 'From: $_POST["eaddress"]';

mail($toEmail, $formSubject, $formComment, $header)) {

The subject and comments are working correctly, but the From: turns the variable into a string.

  • 写回答

1条回答 默认 最新

  • doubaoxue5788 2018-01-24 17:35
    关注
    $header= 'From:' . $_POST["eaddress"];
    

    In your code, $_POST["eaddress"] was in a single quote, it would not be evaluated.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?