简体   繁体   中英

stream_socket_enable_crypto() Error in php mailer

i have Used PHP 5.3 and i have tried to send mail using php mailer LIBRARY.. but i got Error

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.

$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";
        }

I got Error 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.

How to fix this Error?

try

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

    $mail->SMTPSecure = false;
    $mail->SMTPAutoTLS = false;

Your PHP installation is missing the SSL extension that allows TLS encryption on streams like this. There are similar questions that have answers to that, such as this one .

You should not be writing any new code for PHP 5.3 - it's no longer supported and may have security holes; updating may give you the wrappers you're missing anyway.

It won't necessarily affect this particular issue, but you've based your code on an obsolete example, and are not loading the PHPMailer classes as the documentation tells you to - make sure you're using the latest version and base your code on the gmail example provided with PHPMailer .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM