AAB
AAB

Reputation: 1654

PHPMailer Error

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:[email protected] : Called Mail() without being connected Mailer Error: The following From address failed: [email protected] : 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 = "[email protected]";
    $mail->Password = "password";
    $mail->SetFrom("[email protected]");
    $mail->Subject = "Test";
    $mail->MsgHTML("Hello World");
    $mail->AddAddress("[email protected]");
    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?

Upvotes: 0

Views: 1512

Answers (4)

AAB
AAB

Reputation: 1654

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.

Upvotes: 0

MeetD
MeetD

Reputation: 1

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' ) );
?>

Upvotes: 0

Freelancer
Freelancer

Reputation: 4778

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

remove the ssl://

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

Upvotes: 3

elitechief21
elitechief21

Reputation: 3054

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://

Upvotes: 0

Related Questions