here is the way iam send email. this does work fine in localhost.
if i put my website online will this method still work? or do i have to use different method of send email.

                $mail = new PHPMailer();
                $mail->IsSMTP(); 
                $mail->SMTPAuth   = true;                  // enable SMTP authentication
                $mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
                $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
                $mail->Port       = 465;                   // set the SMTP port for the GMAIL server
                $mail->Username = "randomperson@gmail.com";    //yourname@yourdomain
                $mail->Password = "12345";           //password

                //to
                $mail->AddAddress($email_p, $user_name_db);
                //subject
                $mail->Subject = "Forgot password";
                //html body
                $mail->IsHTML(true);
                $mail->Body = "Hello $first_name_db,<br/><br/>
                                Your Username is <u>$user_name_db</u> and your password is <u>$password_db</u><br/><br/>
                                    Thanks,<br/>randomperoson";
                //from
                $mail->From = "randomperoson@gmail.com";
                $mail->FromName = "random";
                $mail->wordWrap = 50;
                //send
                if(!$mail->send())
                {
                    $forgot_error .= "Mail error ".$mail->ErrorInfo;
                }
                else
                {
                    $forgot_error .= "E-mail has be sent to <b><u>$email_p</u></b>";
                }

Since you are using gmail, it should work the same as on your localhost.

If on your site enabled smtp port, this method send will be work.
if no you must use other method of send email.

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.