【问题标题】:I'm getting this Error while sending the form我在发送表单时收到此错误
【发布时间】:2022-01-24 14:04:07
【问题描述】:

AvailableSomething Wrong SMTP connect() 失败。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting。 我的密码和电子邮件正确,并且我的 SSL 已打开。 这是我的代码:

<?php
echo !extension_loaded('openssl')?"Not Available":"Available";
$news = $_REQUEST['news'];
require 'phpmailer/PHPMailerAutoload.php';
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$mail= new PHPMailer;
$mail->Host = "ssl://smtp.gmail.com";
$mail->Port=587;
$mail->isSMTP();
$mail->SMTPAuth=true;
$mail->SMTPSecure='ssl';
$mail->Username='omer.subohh@gmail.com';
$mail->Password='mypassword';
$mail->setFrom('omer.subohh@gmail.com', 'FixHub');
$mail->addAddress('omer.subohh@gmail.com', 'FixHub');     //Add a recipient
$mail->isHTML(true);
$mail->Subject = 'New Subscriber For FixHub NewsLetters';
$mail->Body = '<h2>'.$news.'</h2>';
if(!$mail->send())
{
  echo "Something Went Wrong";
  echo $mail->ErrorInfo;
}
else{
    header("Location: index.php");
}
?>

【问题讨论】:

  • 正如您在按照错误消息中的故障排除指南链接时了解到的那样,ssl 加密模式和端口 587 的组合将不起作用。您需要端口 465 才能使用该模式。您还运行了一个非常旧且不受支持的版本,可能容易受到攻击,因此请升级。

标签: php forms phpmailer


【解决方案1】:

您应该将 ssl://smtp.gmail.com 更改为 smtp.gmail.com

并将 SMTPSecure 更改为“tls”

主机名不应包含加密类型

【讨论】:

  • 还是同样的错误
  • @Abdulrahman 我已经编辑了我的答案,现在检查
  • 还是同样的错误
  • 不,ssl 前缀就可以了。
  • @Synchro 它会很好,虽然谷歌自己建议使用 TLS。
猜你喜欢
  • 2013-01-26
  • 1970-01-01
  • 2011-04-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-31
  • 2018-12-23
相关资源
最近更新 更多