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.

图片转代码服务由CSDN问答提供 功能建议

如何将$ _POST变量分配给PHP邮件程序()'From:'标题参数?</ p>

以下是我的尝试:</ p>

  $ toEmail =“email@example.com”; 
 $ formSubject = $ _ POST [“esubject”];  
 $ formComment = $ _ POST [“comment”]; 
 $ header ='From:$ _POST [“eaddress”]'; 
 
mail($ toEmail,$ formSubject,$ formComment,$ header)){\  n </ code> </ pre> 
 
 

主题和注释正常工作,但From:将变量转换为字符串。</ p> </ div>

1条回答 默认 最新

相关推荐 更多相似问题