Record is inserting but email is not going..

if($_POST['registersubmit'])
{
    $to="'".$_POST['email']."'";
    include('db.php');

    $checkemail=mysql_num_rows(mysql_query("select * from   authentications where email='".$_POST['email']."'"));
    if($checkemail)
        header("Location:".$_SERVER['PHP_SELF']."?msg=E-Mail Already Exists ");
    else
    {
        $query="insert into authentications (password, authcode, email, status, created_at) 
                values ('".$_POST['password']."', '".md5($_POST['email'])."', '".$_POST['email']."', 0, '".date('Y-m-d h:i:s')."')";

        if(mysql_query($query))
            {
                $headers1  = 'MIME-Version: 1.0' . "\r\n"; 
                $headers1 .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
                $headers1 .= "From: Delhi Certificates \r\n"; 
                $headers1 .= "Organization: Delhi Certificates\r\n"; 
                $Subject1  = "Your account has been registered. Thank you!";

                $msg="
                You recently registered for Delhi Certificates using this email address. To complete your registration, follow the link below:
                http://www.mobile9.com/register.php?authcode=e3dd578882c18b1dcf9f741fc20fc195&email=".$_POST['email']."
                (If clicking on the link doesn't work, try copy and paste it into your browser.)
                If you did not register for mobile9.com, please disregard this message.
                Thanks,
                Delhi Certificates
                ";
        //      echo $msg;
        //      echo $to, $Subject1, $msg, $headers1;
                $success = mail($to, $Subject1, $msg, $headers1);
        //      header("Location:".$_SERVER['PHP_SELF']."?msg=Email hass been sent ");
            }
    }
}

Windows or *nix? Local development, or production server? What is the value of $success ? Have you tried $to without adding the quotes? Have you tried to specify a valid from email address in the header?

Linux Environment and It is on production server..
If I use only mail function and use hard coded email in parameter then It works.
$success is not having any use..

$to="'".$_POST['email']."'";

Change to:

$to = $_POST['email'];

Adding the quotes is likely invalidating the address.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.