SSL连接错误:140770FC [英] SSL connection error:140770FC
问题描述
这是用于自动发送邮件的php代码。
This the php code for automatic mail sending.
<?php
$mailto = $_POST['mail_to'];
$mailSub = $_POST['mail_sub'];
$mailMsg = $_POST['mail_msg'];
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail ->IsSmtp();
$mail ->SMTPDebug = 4;
$mail ->SMTPAuth = true;
$mail ->SMTPSecure = 'ssl';
$mail ->Host = "smtp.gmail.com";
$mail ->Port = 587; // or 465
$mail ->IsHTML(true);
$mail ->Username = "rajaramkumar96@gmail.com";
$mail ->Password = "************************";
$mail ->SetFrom("rajaramkumar96@gmail.com");
$mail ->Subject = $mailSub;
$mail ->Body = $mailMsg;
$mail ->AddAddress($mailto);
if(!$mail->Send())
{
echo "Mail Not Sent";
}
else
{
echo "Mail Sent";
}
?>
运行代码后,出现如下错误。
after running the code i get this error as followed.
2018-03-08 01:33:32连接:打开ssl://smtp.gmail.com:587,超时= 300,options = array()
2018-03-08 01 :33:33连接失败。错误#2:stream_socket_client():SSL操作失败,代码为1。OpenSSL错误消息:error:140770FC:SSL例程:SSL23_GET_SERVER_HELLO:未知协议[C:xampp\htdocs\email\PHPMailer\class.smtp .php第298行]
2018-03-08 01:33:33连接失败。错误#2:stream_socket_client():无法启用加密[C:\xampp\htdocs\email\PHPMailer\class.smtp.php第298行]
2018-03-08 01:33: 33连接失败。错误2:stream_socket_client():无法连接到ssl://smtp.gmail.com:587(未知错误)[C:\xampp\htdocs\email\PHPMailer\class.smtp.php行298]
2018-03-08 01:33:33 SMTP错误:无法连接到服务器:(0)
SMTP connect()失败。
2018-03-08 01:33:32 Connection: opening to ssl://smtp.gmail.com:587, timeout=300, options=array () 2018-03-08 01:33:33 Connection failed. Error #2: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol [C:\xampp\htdocs\email\PHPMailer\class.smtp.php line 298] 2018-03-08 01:33:33 Connection failed. Error #2: stream_socket_client(): Failed to enable crypto [C:\xampp\htdocs\email\PHPMailer\class.smtp.php line 298] 2018-03-08 01:33:33 Connection failed. Error #2: stream_socket_client(): unable to connect to ssl://smtp.gmail.com:587 (Unknown error) [C:\xampp\htdocs\email\PHPMailer\class.smtp.php line 298] 2018-03-08 01:33:33 SMTP ERROR: Failed to connect to server: (0) SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
推荐答案
在端口587上使用SMTPSecure ='tls'。
Use SMTPSecure = 'tls' with port 587.
ssl是465 (smtps?),但非常过时。
ssl is 465 (smtps?), but very outdated.
这篇关于SSL连接错误:140770FC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!