I'm trying to use the mail() function in PHP, but it's not working. I'm wondering if "From:" in the header parameter needs to be an existing e-mail address.
My code:
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Email Test</title>
</head>
<body>
    <form>
        <input type="text" name="to" placeholder="Reciever">
        <br>
        <br>
        <input type="text" name="subject" placeholder="Subject">
        <br>
        <br>
        <input type="text" name="from" placeholder="sender">
        <br>
        <br>
        <input type="text" name="cc" placeholder="CC">
        <br>
        <br>
        <textarea type="text" name="message" placeholder="Message" rows="15" cols="50"></textarea>
        <br>
        <br>
        <button type="submit" name="submit" value="submit">Send</button>
    </form>
    <br>
<?php
session_start();
if (isset($_GET["submit"]) && $_SESSION["user_id"] > 0) {
    $to = $_GET["to"];
    $subject = $_GET["subject"];
    $message = $_GET["message"];
    $sender = $_GET["sender"];
    $cc = $_GET["cc"];
    $headers = sprintf("From: %s" . "\r\n" .
    "CC: %s", $sender, $cc);
    mail($to, $subject, $message, $headers);
    echo $to."\n".$subject."\n".$message."\n".$headers."\n";
}
?>
</body>
</html>
I tried to get input from the user using the and tags, but that doesn't seem to work. Then, I tried without that input and it still didn't work.
