我希望以 HTML 格式发送一封电子邮件,并且在这封电子邮件中我需要从 php 表单传递数据。电子邮件作为 html 电子邮件成功发送,但不显示从 PHP VARIABLE 传递的数据。
$name = "PHP TEXT";
$headers = "From: " ."mail@example.com" . "\r\n";
$headers .= "Reply-To: ". "mail@example.com" . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = "<html><body><h1>HTML TEXT <?php echo $name; ?></h1></body></html>";
$email_to = 'example@mail.com'; //the address to which the email will be sent
$subject = "test";
$email = "example@mail.com";
if (mail($email_to, $subject, $message, $headers)) {
echo 'sent'; // success
} else {
echo 'failed'; // failure
}