not sure why this mail isnt working. when i run this code i get a error:

Mail error SMTP Error: Could not connect to SMTP host.

i set up a if test which is failing. doesnt any one know how to connect to smtp host? does this smtp means the files? bc i did include it top of the page. and also phpmailer.php

...
require_once('require/class.phpmailer.php');  
require_once('require/class.smtp.php');      
    ...


                $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 = "username@gmail.com";    //yourname@yourdomain
                $mail->Password = "password";           //password

                $mail->AddAddress($email_p, $first_name_db);
                $mail->Subject = "Forgot password";
                $mail->IsHTML(true);
                $mail->Body = "message";

                $mail->From = "username@gmail.com";
                $mail->FromName = "fromname";
                $mail->wordWrap = 50;

                if(!$mail->send())
                {
                    $e .= "Mail error ".$mail->ErrorInfo;
                    echo"$e";
                }
                else
                {
                    echo "E-mail has be sent to <b><u>$email_p</u></b>";
                }

Recommended Answers

All 3 Replies

it is your hosting server error talk to them i have similer error my hosting provider solve this problem.

but i dont have a hosting server. this is on localhost.

then i think you have to test it on server i test my phpmailer function on server and then i get this error and this error is from my host provider

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.