PHPMailer – 此流不支持SSL /加密
发布时间:2020-05-25 09:01:08 所属栏目:PHP 来源:互联网
导读:我正在尝试让 PHPMailer工作并继续收到此错误: PHP Warning: stream_socket_enable_crypto(): this stream does not support SSL/crypto in /usr/share/php5/class.smtp.php on line 274 我已经看到一些帖子,人们通过取消注释来修复问题: 延长= php_open
我正在尝试让 PHPMailer工作并继续收到此错误: PHP Warning: stream_socket_enable_crypto(): this stream does not support SSL/crypto in /usr/share/php5/class.smtp.php on line 274 我已经看到一些帖子,人们通过取消注释来修复问题: 我做了 – 并重新启动了apache. 有任何想法吗? 这是我正在使用的php示例代码: 在OpenSuse 12.3上运行php 5.3.17和Apache 2.2.22 <?php require_once('class.phpmailer.php'); include("class.smtp.php"); // optional,gets called from within class.phpmailer.php if not already loaded $mail = new PHPMailer(); $body = file_get_contents('contents.html'); $body = eregi_replace("[]",'',$body); $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "mail.yourdomain.com"; // SMTP server $mail->SMTPDebug = 1; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "tls"; // sets the prefix to the servier $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $mail->Port = 587; // set the SMTP port for the GMAIL server $mail->Username = "my email address"; // GMAIL username $mail->Password = "my password"; // GMAIL password $mail->SetFrom('name@yourdomain.com','First Last'); $mail->AddReplyTo("name@yourdomain.com","First Last"); $mail->Subject = "PHPMailer Test Subject via smtp (Gmail),basic"; $mail->AltBody = "To view the message,please use an HTML compatible email viewer!"; // optional,comment out and test $mail->MsgHTML($body); $address = "whoto@otherdomain.com"; $mail->AddAddress($address,"John Doe"); if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } ?>问题解决了. 在opensuse上我必须安装php5-openssl 重启apache – 现在全部工作100%. (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |