Reputation: 790
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 = "[email protected]";
$sendtoname = 'yyyy';
$sendto = '[email protected]';
$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 = '[email protected]';
$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?
Upvotes: 0
Views: 6602
Reputation: 31
try
$mail->smtpConnect = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail->SMTPSecure = false;
$mail->SMTPAutoTLS = false;
Upvotes: 3
Reputation: 37730
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.
Upvotes: 0