How to format php mail?

6

I'm not able to insert formatting into code. Whenever I send, I get the email formatting tags as <html> <body> , <strong> , <b> , <p> , etc ...

Follow the code with html formatting that does not work.

    $to = $your_email;
    $subject="Pedido $numeroPedido de $name";
    $from = $your_email;
    $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';

    $html ="
    <p><b>$name</b> enviou um arquivo mensagem:</p>
    <p><b>Número do Pedido:</b> $numeroPedido</p>   
    <p><b>Endereço:</b> $endereco</p>
    <p><b>Endereço:</b> $estado</p>     
    <p><b>Cidade:</b> $cidade</p>
    <p><b>Telefone:</b> $telefone
    <p><b>Celular:</b> $celular</p>                         
    <p><b>Email:</b> $visitor_email</p>
    <p><b>Informações Adicionais:</b></p>
    <p>$user_message</p>
    <p><b>IP:</b> $ip</p>
    ";  

    $headers = "From: $from \r\n";
    $headers .= "Reply-To: $visitor_email \r\n";

    if (mail($to, $subject, $html, $headers)) {

Thanks in advance =)

    
asked by anonymous 30.07.2015 / 22:17

1 answer

5

Add a header, defined which will be the email type, text / plain (default) or text / html. There are other more practical options for this, such as phpMailer or swiftMailer .

$headers = "From: $from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
$headers .= 'Content-type: text/html;' . "\r\n";
    
30.07.2015 / 22:20