fsockopen() error about sending mail in php

rockenpeace picture rockenpeace · Jul 18, 2012 · Viewed 11.1k times · Source

I want to send a confirmation e-mail to user when the user has registered. I am using xampp. When I run my php file, it returns the following error:

    Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in C:\xampp\htdocs\class.smtp.php on line 122

    Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in C:\xampp\htdocs\class.smtp.php on line 122
    Message has not been sent. 

Related part in my php file :

try
    {
        require("class.phpmailer.php");
        $mail = new PHPMailer();   
        $mail->IsSMTP();
        $mail->Mailer = "smtp";
        $mail->SMTPSecure = "ssl"; 
        $mail->Host = "ssl://smtp.gmail.com";
        $mail->Port = 465;
        $mail->SMTPAuth = true;
        $mail->CharSet="utf-8";
        $mail->Username = "[email protected]";
        $mail->Password = "password";
        $mail->From     = "[email protected]";
        $mail->FromName="DBE Yazılım";
        $mail->AddAddress($_POST['UserMail']); 
        $mail->Subject  = "Registration Information";
        $mail->Body     = "Hello your password is " . $userpass;
        //$mail->AddAttachment($path);
        $mail->Send();
        if($mail->Send())
            echo 'Message has been sent.';
        else
            echo 'Message has not been sent.';
    }
    catch(Exception $e)
    {
        echo 'hata'.$e->getMessage();
    }

I have looked at forums and this error is generally about ssl. They say that extension=php_openssl.dll must add into php.ini. I added this part but anything did not change. Is this about xampp?

Thanks in advance.

Answer

KingCrunch picture KingCrunch · Jul 18, 2012

As you can see in the error message

unable to connect to ssl://ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in C:\xampp\htdocs\class.smtp.php on line 122

there is one ssl:// too much

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

Usually if you see the term "host", this really means "host" and not an url