我使用SMTP连接发送电子邮件。在它工作正常之前的一个月没有工作。我无法得到该错误的实际原因。
错误是:
SMTP -> ERROR: Failed to connect to server: A connection attempt failed because the
connected party did not properly respond after a period of time, or established
connection failed because connected host has failed to respond. (10060)
我的代码是:
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "emailid@gmail.com";// GMAIL username
$mail->Password = "xxxxxxx";// GMAIL password
$mail->AddAddress("somthing@gmail.com", "Somthing");
$mail->Subject = "Test Subject";
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML(utf8_decode("HTML Content"));
$mail->Send();