1

我试图通过 mailer.php 页面在主题行中显示两个连接变量,但电子邮件中的主题行始终为空白。下面是相关代码。

/* Subject and To */

$to = 'nnorman@dimplexthermal.com';
$subject = $company . ' ' . $name;

/* Gathering Data Variables */

$name = $_POST['name'];
$email = $_POST['email'];
$company = $_POST['company'];

$body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Company: $company <br>

EOD;

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($to, $subject, $body, $headers);
4

1 回答 1

4
$to = 'nnorman@dimplexthermal.com';
$subject = $company . ' ' . $name;

/* Gathering Data Variables */

$name = $_POST['name'];
$email = $_POST['email'];
$company = $_POST['company'];

你没有设置$company$name直到你使用它们之后$subject

尝试换行:

/* Gathering Data Variables */

$name = $_POST['name'];
$email = $_POST['email'];
$company = $_POST['company'];

$to = 'nnorman@dimplexthermal.com';
$subject = $company . ' ' . $name;
于 2012-08-21T20:25:41.267 回答