0

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
failed

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

                    if(mail($to, $subject, $message, $headers))  //lline 49
                    {
                    echo "message successfully sent";
                    } 
                    else
                    { 
                        echo "failed";
                    }
4
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by Transcendent
0

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".

Edited by pank001: more accurate

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.