我的联系表中的邮件布局有问题

我需要有关联系表格布局的帮助,这是我的问题:


当我收到来自我的联系表的邮件时,我的 /r 或 /n 似乎不起作用我将我的表单的所有内容都放在一行中,我不知道为什么。


这是我的代码:


<?php


if (isset($_POST)) {


    $lastName = $_POST['lastName'];

    $firstName = $_POST['firstName'];

    $speciality = $_POST['speciality'];

    $adress = $_POST['adress'];

    $phone = $_POST['phone'];

    $mailFrom = $_POST['email'];

    $txt = $_POST['message'];


    $to = "mymail@mymail.com";

    $subject = utf8_decode("Expéditeur : ".$lastName." ".$firstName);

    $message = 'Vous avez reçu un email de ' . $lastName . "\r\n" .  $firstName . "\r\n" . $speciality . "\r\n" . $adress . "\r\n" . $phone . "\r\n" . $mailFrom . "\r\n" .$txt;

    $headers  = 'MIME-Version: 1.0' . "\r\n";

    $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";

    $headers .= 'From: '.$mailFrom."\r\n";

    $headers .= 'Reply-To: '.$mailFrom."\r\n";


    mail($to, $subject, $message, $headers);

    header("Location: /");

}

请任何人都可以帮助我。多谢。


守着星空守着你
浏览 74回答 1
1回答

翻阅古今

你只需要用"\r\n"html<br>标签改变<?php&nbsp; &nbsp; if (isset($_POST)) {&nbsp; &nbsp; &nbsp; &nbsp; $lastName = $_POST['lastName'];&nbsp; &nbsp; &nbsp; &nbsp; $firstName = $_POST['firstName'];&nbsp; &nbsp; &nbsp; &nbsp; $speciality = $_POST['speciality'];&nbsp; &nbsp; &nbsp; &nbsp; $adress = $_POST['adress'];&nbsp; &nbsp; &nbsp; &nbsp; $phone = $_POST['phone'];&nbsp; &nbsp; &nbsp; &nbsp; $mailFrom = $_POST['email'];&nbsp; &nbsp; &nbsp; &nbsp; $txt = $_POST['message'];&nbsp; &nbsp; &nbsp; &nbsp; $to = "mymail@mymail.com";&nbsp; &nbsp; &nbsp; &nbsp; $subject = utf8_decode("Expéditeur : ".$lastName." ".$firstName);&nbsp; &nbsp; &nbsp; &nbsp; $message = '&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <html>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <head>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <title>Welcome to Website Name</title>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </head>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <body>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <p> Vous avez reçu un email de '. $lastName .'<br>'.&nbsp; $firstName .'<br>'. $speciality .'<br>'. $adress .'<br>'. $phone .'<br>'. $mailFrom .'<br>'. $txt .'</p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </body>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </html>&nbsp; &nbsp; &nbsp; &nbsp; ';&nbsp; &nbsp; &nbsp; &nbsp; $headers = "MIME-Version: 1.0" . "\r\n";&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";&nbsp; &nbsp; &nbsp; &nbsp; $headers .= 'From: '.$mailFrom."\r\n";&nbsp; &nbsp; &nbsp; &nbsp; $headers .= 'Reply-To: '.$mailFrom."\r\n";&nbsp; &nbsp; &nbsp; &nbsp; mail($to, $subject, $message, $headers);&nbsp; &nbsp; &nbsp; &nbsp; header("Location: /");&nbsp; &nbsp; }?>
打开App,查看更多内容
随时随地看视频慕课网APP