php mail()/ r/n和<br>没有任何效果

use*_*848 3 php email newline

我已经看了一些解决方案,但没有一个有效.

<?php
    $name = $_POST['name'] . "<br>" ;
    $email = $_POST['email'] . "/r/n";
    $phone = $_POST['phone'] . "/r/n";
    $message = $_POST['message'] . "/r/n";
    $from = 'From: email@place.com';
    $to = 'mail@otherplace.com';
    $subject = 'subject here';

    $body = "From: $name E-Mail: $email Phone: $phone $message"
?>
<?php
    if ($_POST['submit']) {
        if (mail ($to, $subject, $body, $from)) {
            echo '<p>Your message has been sent</p>';
        }else{
            echo '<p>Something went wrong, go back and try again.</p>';
        }
    }
?>
Run Code Online (Sandbox Code Playgroud)

这不仅显示一行中的所有内容,还显示/ r/n和
标记,就好像它们只是文本一样.

Fun*_*ner 13

简单:

您需要将所有内容更改/r/n\r\n

现在为了<br>有效,你需要在你的headers

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
Run Code Online (Sandbox Code Playgroud)

有关mail()和的更多信息,请参阅PHP手册headers()