【问题标题】:stream_socket_enable_crypto() Error in php mailerphp邮件程序中的stream_socket_enable_crypto()错误
【发布时间】:2017-06-24 20:33:53
【问题描述】:

我使用过 PHP 5.3,我尝试使用 php mailer LIBRARY 发送邮件.. 但我收到错误

警告:stream_socket_enable_crypto() [streams.crypto]:此流不支持 SSL/crypto 在 D:\xampp\htdocs\mail_check\mail\class.smtp.php 行 313 邮件程序错误:SMTP 连接()失败。

$sendfrm_name = "xxxx";
        $sendfrm_id = "ddsdsd@gmail.com";

        $sendtoname = 'yyyy';
        $sendto = 'yyyyyy@gmail.com';

        $cc = '';

        include("mail/PHPMailerAutoload.php");
        include("mail/class.PHPMailer.php");
        include("mail/class.smtp.php");

        $mail = new PHPMailer;
        $mail-> isSMTP();
        $mail-> Host = 'smtp.gmail.com';
        $mail-> SMTPAuth = true;
        $mail->smtpConnect = array(
        'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
        )
        );
        $mail-> Username = 'fffffff@gmail.com';
        $mail-> Password = 'ekdbaffdfba..';
        $mail-> SMTPSecure = 'tls';
        $mail-> Port = 587; //587
        $mail-> setFrom($sendfrm_id, $sendfrm_name);
        $mail-> addAddress($sendto, $sendtoname);
        $mail-> addReplyTo($sendto, $sendtoname);
        //$mail->addCC($cc);
        $mail->WordWrap = 50;
        $mail->isHTML(true);
        $mail->Subject = "Test Mail";
        $mail->Body = "Name: ".$sendfrm_name ."<br /> Email: ".$sendfrm_id;
        if(!$mail->send())
        {
            echo "Mailer Error: ".$mail->ErrorInfo;
        }
        else
        {
            echo "1";
        }

我收到错误Warning: stream_socket_enable_crypto() [streams.crypto]: this stream does not support SSL/crypto in D:\xampp\htdocs\mail_check\mail\class.smtp.php on line 313 Mailer Error: SMTP connect() failed.

如何解决这个错误?

【问题讨论】:

    标签: php email phpmailer


    【解决方案1】:

    试试

        $mail->smtpConnect = array(
            'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => true
            )
        );
    
        $mail->SMTPSecure = false;
        $mail->SMTPAutoTLS = false;
    

    【讨论】:

    • 您能否解释一下为什么会这样?
    • $mail->SMTPAutoTLS = false;为我做了伎俩。我只是使用 SMTPSecure 为 false,但还不够。
    【解决方案2】:

    您的 PHP 安装缺少允许对此类流进行 TLS 加密的 SSL 扩展。有类似的问题有答案,例如this one

    您不应该为 PHP 5.3 编写任何新代码 - 它不再受支持并且可能存在安全漏洞;无论如何,更新可能会为您提供您缺少的包装器。

    它不一定会影响这个特定问题,但您的代码基于一个过时的示例,并且没有按照文档告诉您加载 PHPMailer 类 - 确保您使用的是 the latest version 和 base你在the gmail example provided with PHPMailer上的代码。

    【讨论】:

      猜你喜欢
      • 2015-08-10
      • 1970-01-01
      • 2011-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多