PHP邮件未发送正文内容

问题描述 投票:0回答:1

我正在发送给在餐厅预订的人的回复电子邮件。我的代码曾经可以工作,但是由于某种原因,它不再发送电子邮件正文。我环顾了StackOverflow,因为其他人也遇到了类似的问题,但是没有建议的修复程序起作用。

请参见以下提交脚本:

$headers = "From: Redacted at Redacted <[email protected]>\n".
$headers .= 'Reply-To: '. strip_tags($_POST['email']) . "\n" .
$headers .= "MIME-Version: 1.0 \n" .
$headers .= "Content-Type: text/html; charset=UTF-8";

// Booking Message

$booking_to = "[email protected]";
$booking_subject = "Table Reservation - " .strip_tags($_POST['date']) . " - " . strip_tags($_POST['time']) . " - " . ucfirst(strip_tags ($_POST['first-name'])). ' ' .ucfirst(strip_tags($_POST['last-name']));

$booking_message = "<html><head>";
$booking_message .= '</head><body style="max-width: 600px; min-width: 200px; margin: 0 auto; padding: 0;">';
$booking_message .= '<!--[if mso]>
<center>
<table><tr><td width="600">
<![endif]-->';
$booking_message .= '<h2 style="font-weight: 400; text-transform: uppercase; margin: 3em 0; font-family: sans-serif; letter-spacing: 5px; color: #0B8F91;">Company Name</h2>';
$booking_message .= '<h1 style="font-weight: 600; margin: 0; font-family: sans-serif; color: #eeeee">Booking Reservation</h1>';
$booking_message .= '<br>';
$booking_message .= '<p style="font-weight: 400; margin: 20px 0; font-family: sans-serif">A booking request has been entered on <a style="font-weight: 400; margin: 20px 0; font-family: sans-serif; color: grey;" href="https://example.com/book">https://example.com/book</a>. <br>See below for the booking details. Press "<b>reply</b>" to contact the customer.</p>';
$booking_message .= '<!--[if mso]>
</td></tr></table>
</center>
<![endif]--> ';
$booking_message = "</body></html>";

@mail($booking_to, $booking_subject, $booking_message, $headers);
header( 'Location: https://example.com/book#book-confirmation' ) ;
}?>

请参阅下面的链接,以获取我收到的电子邮件:Received Email

我曾尝试将\n更改为\r,然后更改为\r\n,但不断出现连续错误,在某些情况下,整个标头变量都停止工作。

非常感谢您的帮助,请确保所有人安全!

php html email html-email
1个回答
0
投票

错误在第$booking_message = "</body></html>";行上。您只用$booking_message替换了整个</body></html>变量。您需要使用字符串附加。

$booking_message .= "</body></html>";
© www.soinside.com 2019 - 2024. All rights reserved.