How to add <hr> in php mail form?

Viewed 80

I want to add a horizontaly line


inside a form content in php. Is that possible?

I write the code below but 'hr' looks like that in my email PR1: product1 PR2: product2 < hr > PR3: product3 PR4: product4

What should I do? Thanks !!!

   <?php
    $product1= $_POST['product1'];
    $product2= $_POST['product2'];
    $product3 = $_POST['product3'];
    $product4 = $_POST['product4'];
    
    $name = $_POST['name'];
    $email = $_POST['email'];
    
  $formcontent=" From: $name \n ST1: $product1 \n PR2: $product2 <hr> \n PR3: $product3 \n PR1: $product4";
    
    $recipient = "form@mycompany.com";
    $subject = "My Products";
    $mailheader = "From: $email \r\n";
    mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
    echo "Thank You!" . " -" . "<a href='form.html' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
    ?>
2 Answers

For <hr/> tag in your email body, you should use HTML email format, which means adding HTML tags and Content-type headers.

You can try this one

  <?php
    $product1= $_POST['product1'];
    $product2= $_POST['product2'];
    $product3 = $_POST['product3'];
    $product4 = $_POST['product4'];
    
    $name = $_POST['name'];
    $email = $_POST['email'];
    
  $formcontent="<html><body> From: $name \n ST1: $product1 \n PR2: $product2 <hr> \n PR3: $product3 \n PR1: $product4 </body></html>";
    
    $recipient = "form@mycompany.com";
    $subject = "My Products";
    $mailheader = "MIME-Version: 1.0" . "\r\n"; 
    $mailheader .= "Content-type:text/html;charset=UTF-8" . "\r\n"; 
    $mailheader .= "From: $email \r\n";

    mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
    echo "Thank You!" . " -" . "<a href='form.html' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
    ?>

put content below or above following div

<div style='width:100%; height : 13px; float:left; border-bottom : 1px solid black;'>&nbsp;</div>
Related