PHPMailer-此流不支持SSL/加密 [英] PHPMailer - this stream does not support SSL/crypto

查看:229
本文介绍了PHPMailer-此流不支持SSL/加密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使PHPMailer正常工作,并不断出现此错误:

I'm trying to get PHPMailer working and keep getting this error:

PHP Warning:  stream_socket_enable_crypto(): this stream does not support SSL/crypto in /usr/share/php5/class.smtp.php on line 274

我看过一些帖子,人们通过不加注释来解决了这个问题: extension = php_openssl.dll

I've seen a few posts where people have fixed the problem by uncommenting this: extension=php_openssl.dll

我已完成-重新启动了Apache.

which I have done - and restarted apache.

有什么想法吗?

这是我正在使用的php示例代码:

Here is the php example code I am using:

在OpenSuse 12.3上运行php 5.3.17和Apache 2.2.22

Running php 5.3.17 and Apache 2.2.22 on OpenSuse 12.3

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

On opensuse I had to install php5-openssl

重新启动apache-现在都可以100%工作了.

Restarted apache - all working 100% now.

这篇关于PHPMailer-此流不支持SSL/加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆