【问题标题】:fsockopen() error about sending mail in php关于在 php 中发送邮件的 fsockopen() 错误
【发布时间】:2012-07-17 10:15:06
【问题描述】:

我想在用户注册后向用户发送确认电子邮件。我正在使用 xampp。当我运行我的 php 文件时,它返回以下错误:

    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. 

我的 php 文件中的相关部分:

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 = "user@gmail.com";
        $mail->Password = "password";
        $mail->From     = "user@gmail.com";
        $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();
    }

我看过论坛,这个错误通常是关于 ssl 的。他们说extension=php_openssl.dll 必须添加到 php.ini 中。我添加了这部分,但没有任何改变。这是关于 xampp 的吗?

提前致谢。

【问题讨论】:

    标签: php ssl smtp xampp fsockopen


    【解决方案1】:

    在 fsockopen() 函数中打开您的服务器 PHP.ini 文件配置。你会看到它的工作......

    【讨论】:

      【解决方案2】:

      正如您在错误消息中看到的那样

      无法连接到 ssl://ssl://smtp.gmail.com:465(无法找到套接字传输“ssl” - 您是否在配置 PHP 时忘记启用它?) 在 C:\xampp\htdocs\class.smtp.php 第 122 行

      ssl:// 太多了

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

      通常,如果您看到“主机”一词,这实际上是指“主机”而不是 url

      【讨论】:

      • 我已更改为 "$mail->Host = "smtp.gmail.com";"但错误不会改变。
      猜你喜欢
      • 1970-01-01
      • 2011-05-05
      • 2010-10-18
      • 2012-10-20
      • 2015-09-14
      • 1970-01-01
      • 1970-01-01
      • 2017-06-24
      • 1970-01-01
      相关资源
      最近更新 更多