0

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>";
                }
2
Contributors
3
Replies
5
Views
4 Years
Discussion Span
Last Post by AARTI SHRIVAS
0

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

Edited by AARTI SHRIVAS

This topic has been dead for over six months. 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.