我确信这很简单,但是我无法解决这个问题而谷歌什么都没给我。我有一个简单的HTML - >我刚刚更改为通过SMTP发送的PHP表单。它工作得很好,但我无法弄清楚如何插入$ _POST类型(它进入一个表;不确定是否重要)。
这是我的HTML表单,用户输入以下信息:
<form id="test" method="post" action="employment-applicationreceived.php">
<div class="backgroundform">
<li id="li_1" >
<label class="description2" for="element_1">Name: </label>
<input id="req_name" name= "req_name" class="element text" maxlength="255" size="28" value=""/>
</form>
这是发送信息的.PHP表单:
<?php
require_once "Mail.php";
require_once "Mail/mime.php";
$from = "Test <test@testing.com>";
$to = "Test <test@testing.com>";
$subject = "Test HTML email using PHP Pear w/ SMTP\r\n\r\n";
$text = "This is a text test email message";
$html = "<html><body><html><body>
<strong>PERSONAL INFORMATION</strong>
<table>
<tr style='background: #999;'><td height='2'></td><td>
<tr><td>First Name: </td><td width='500'>$req_name = $_POST['req_name'];</td>
</table></body></html>";
$crlf = "\n";
$mime = new Mail_mime($crlf);
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$host = "hostname";
$port = "25";
$username = 'test@testing.com';
$password = '***';
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$body = $mime->get();
$headers = $mime->headers($headers);
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("
" . $mail->getMessage() . "
");
} else {
echo("
Message successfully sent!
");
}
?>
答案 0 :(得分:2)
您只有""
之外的帖子值。更改您的$html
,如下所示:
$html = "<html><body><html><body>
<strong>PERSONAL INFORMATION</strong>
<table>
<tr style='background: #999;'><td height='2'></td><td>
<tr><td>First Name: </td><td width='500'>".$_POST['req_name']."</td>
</table></body></html>";