0
votes

SMTP -> ERROR: Failed to connect to server: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060) The following From address failed:id@gmail.com : Called Mail() without being connected Mailer Error: The following From address failed: id@gmail.com : Called Mail() without being connected

I am not able to send email I get the above error. Here`s the code

<?php require_once("Project/function/PHPMailer/class.phpmailer.php");

    $mail = new PHPMailer(); // create a new object
    $mail->IsSMTP(); // enable SMTP
    $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
    $mail->SMTPAuth = true; // authentication enabled
    $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
    $mail->Host = "ssl://smtp.gmail.com";
    $mail->Port = 465; // or 587
    $mail->IsHTML(true);
    $mail->Username = "id@gmail.com";
    $mail->Password = "password";
    $mail->SetFrom("id@gmail.com");
    $mail->Subject = "Test";
    $mail->MsgHTML("Hello World");
    $mail->AddAddress("id@gmail.com");
    if(!$mail->Send()){
        echo "Mailer Error: " . $mail->ErrorInfo;
    }
    else{
        echo "Message has been sent";
        }


?>

I am using wamp ver 2.4. The wamp server is offline.The Open SSL extension is enabled have checked the php.ini file the ; has been removed from open ssl dll.

Is using PEAR better?

4
Seems your mailing server refusing connection, perhaps the subject port is closed on you server that you tried to connect from.Valentin Rusk
my Colleges Firewall might be the reason working fine from my dongle sorry for wasting your time should have checked it from my dongle beforeAAB
Great. It just happens too often due to not standard port usage. These are true to be closed if not used.Valentin Rusk

4 Answers

3
votes
$mail->Host = "ssl://smtp.gmail.com";

remove the ssl://

$mail->Host = "smtp.gmail.com";
0
votes

Just using this works for me:

 $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
 $mail->Host = "smtp.gmail.com";

Try getting rid of the ssl://

0
votes

try with adding only,

$mail->SMTPSecure = 'tls';

Also check PHP is using openSSL extension, you can check this in php.ini file and search extension=php_openssl.dll

<?php
var_dump( extension_loaded( 'openssl' ) );
?>
0
votes

I was connected to my College Network before.I guess the college firewall had something to do with errors.

Using Dongle to access net its working fine now.