1

Here is my code:

 <?php
    header('Content-type: text/plain; charset=utf-8');

    $to = 'example@gmail.com';
    $subject = 'Message to the site';

    $realname = htmlspecialchars($_POST['realname']);
    $email = htmlspecialchars($_POST['email']);
    $msg = htmlspecialchars($_POST['msg']);

    $headers = 'From: example@gmail.com' . "\r\n" .
        'Reply-To: example@gmail.com' . "\r\n" .
        'X-Mailer: PHP/' . phpversion();


    mail($to, $subject, $msg, $headers) or die("Error!");
    echo 'Thank you! :)';
?>

Could somebody explaing me - why this code does not work properly? I meant that, when I click button submit, it send the email, but I could not include $msg in it and I don't know why.

1 Answers1

0

Try to add :

$headers .= 'Content-type: text/html';

Add this line under $headers and than check i hope this will work for you...

DeDevelopers
  • 533
  • 1
  • 6
  • 25