smtp_error:无法连接到服务器

时间:2012-07-09 06:56:52

标签: php openssl phpmailer

我已经关注了代码

 phpinfo();

       $mail = new PHPMailer();
        $mail->IsSMTP();  // telling the class to use SMTP
        $mail->SMTPSecure = "ssl";
        $mail->Host     = "smtp.gmail.com"; // SMTP server
        $mail->Port = 465;


            $mail->SMTPAuth = true; 
            $mail->Username= 'someone@gmail.com';
            $mail->Password='xxx';
            $mail->From  = "someone@gmail.com";
            $mail->AddAddress("abc@gmail.com");

            $mail->Subject  = "First PHPMailer Message";
            $mail->Body     = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
            $mail->WordWrap = 50;
        if(!$mail->Send()) {
          echo 'Message was not sent.';
          echo 'Mailer error: ' . $mail->ErrorInfo;
        } else {
          echo 'Message has been sent.';
        }

我还在php.ini文件中启用了“extension = php_openssl.dll”..

但仍然给我一个错误,

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

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

虽然我的php.ini文件中启用了extension=php_openssl.dll,但phpinfo();显示OpenSSL support:disabled (install ext/openssl)。怎么可能?

任何人都可以帮忙吗?

3 个答案:

答案 0 :(得分:0)

$mail->SMTPSecure = "ssl";

我遇到了这个问题。检查您的PHPMailer版本是否是最新的

答案 1 :(得分:0)

这意味着您的ssl模块无法正确编译或已编译但未通过php.ini配置文件启用。

检查您的设置以确保已启用它。

答案 2 :(得分:0)