PHP邮件-在html邮件中使用php字符串

时间:2018-11-19 10:58:01

标签: php string

这是我的代码:

$to = 'info@example.de';
$subject = 'Test Subject';
$data = "". echo (rand(12448, 13451)); ."";

$headers = "From: " . strip_tags($_POST['req-email']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";
$headers .= "Content-Type: text/html;";

$message = '<html>';
$message .= '<td style="color:#ffffff;font-family:Arial,sans-serif;font-size:28px;line-height:36px;text-align:left">'. $data .'</td>';
$message .= '<&/html>';


if(mail($to, $subject, $message, $headers)){
    echo 'Your mail has been sent successfully.';
} else {
    echo 'Unable to send email. Please try again.';
}

我没有在HTML电子邮件输出中正确显示$data

我需要帮助人员,如果您能帮助我在HTML电子邮件中显示php字符串,将不胜感激。

2 个答案:

答案 0 :(得分:2)

$data = "". echo (rand(12448, 13451)); ."";行不应该这样写。我很惊讶它不会为您带来任何错误。如果您只是将其更改为:

$data = rand(12448, 13451));

它应该可以正常工作。

答案 1 :(得分:1)

您应该更改此行:

$data = rand(12448, 13451);