PHP Mail不发送正文内容

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

请参阅以下提交脚本:

$headers = "From: Redacted at Redacted <no-reply@redacted.com>\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 = "redacted@redacted.com";
$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' ) ;
}?>

See the link below for the email I receive: Received Email

I've tried changing the \n to \r and then \r\n but keep getting continuous errors and in some cases, the whole of the header variable stops working.

非常感谢您的帮助,请大家注意安全!

评论