it always goes to echo "failed;" and print error:
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\login_test\forgotpassword.php on line 49

                     $to = $email;
                    $subject = "Forgot password";
                    $message = "Hi $firstname_db,\n Your password is $password_db";
                    $headers = "from:";

                    if(mail($to, $subject, $message, $headers))  //lline 49
                    echo "message successfully sent";
                        echo "failed";

Some people was saying that it won't work if someone is using localhost but I'm not sure.

The above code to send mails from localhost will always show an error; though
it will work fine on global servers when you put the project online.

If you want to remove the error cofiqure "Mercury" in XAMPP Control Panel.

In Mercury, go to Configuration > MercuryS SMTP Server

Now in new SMTP config dialog box go to "Connection Control" tab
and uncheck the first check box labeled as "Do not permit SMTP relaying of non-local mail"

Now the above error is gone but the mail you send would not be delivered coz the mail servers of all popular service provider will refuse to accept the mails originated from "localhost".

they error is gone.
but so email wont be send? do you know how can i send it?