Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPMailer - this stream does not support SSL/crypto

Tags:

php

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

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

<?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('[email protected]', 'First Last');

$mail->AddReplyTo("[email protected]","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 = "[email protected]";
$mail->AddAddress($address, "John Doe");

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}

?>
like image 911
Greg Avatar asked Oct 22 '22 00:10

Greg


1 Answers

Problem solved.

On opensuse I had to install php5-openssl

Restarted apache - all working 100% now.

like image 161
Greg Avatar answered Nov 03 '22 04:11

Greg