php 的sentmail支持ssl吗,PHPMailer-此流不支持SSL /加密

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

I've seen a few posts where people have fixed the problem by uncommenting this:

extension=php_openssl.dll

which I have done - and restarted apache.

Any ideas?

Here is the php example code I am using:

Running php 5.3.17 and Apache 2.2.22 on OpenSuse 12.3

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!";

}

?>

解决方案

Problem solved.

On opensuse I had to install php5-openssl

Restarted apache - all working 100% now.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值