I don't understand what is the wrong

<?php
                    $to = "example@gmail.com";
                    $subject = "test";
                    $message = "
<html>
<head>
   
</head>
<body>
    <h1>Hello world</h1>
</body>
</html>
";
                    $headers = "MIME-Version: 1.0" . "\r\n";
                    $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
                    $headers = "From: user@example.com>";
                    
                    if (mail($to, $subject, $message, $headers)) {
                      echo "Email sent successfully";
                    } else {
                        echo "Email sending failed...";
            }

?>

    You haven't said anything about what is happening. Are you being told "Email sending failed..."? Are you being told it was sent successfully but it isn't received? Are you getting a bunch of error messages? What?

    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
    $headers = "From: user@example.com>";

    One problem is that because you're using = instead of .= on the third line here, you end up losing the first two lines and replacing them with the third, instead of adding the third line to the other two.
    That > shouldn't be there either.

    kumerbakul mail send successfully but not HTML format it's sent text format

    So the rest of my post is relevant, then.

      I.e., I might do this, to make sure I don't have to worry about whether I use = or .=...

      $headers = implode("\r\n", [
          "MIME-Version: 1.0",
          "Content-type:text/html;charset=UTF-8",
          "From: user@example.com"
      ]);
      

      ...with the added benefit of making it easy to add, remove, or edit headers as/when needed.

        Write a Reply...