PHPMailer:SMTP错误:无法使用godaddy连接到服务器(0)



我得到错误:

2020-05-03 02:33:55 SMTP ERROR: Failed to connect to server: (0)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

我已经查看了我能找到的所有GoDaddy文章和堆栈文章,并尝试了他们的解决方案,比如更改端口等。我还尝试了我的Gmail和cPanel网络/电子邮件帐户。然而,针对这个错误的大多数解决方案与GoDaddy无关,它们的解决方案与XAMPP等有关。非常感谢您的帮助:(

作为参考,这里是PHP代码:

use PHPMailerPHPMailerPHPMailer;
use PHPMailerPHPMailerSMTP;
use PHPMailerPHPMailerException;

require 'src/Exception.php';
require 'src/PHPMailer.php';
require 'src/SMTP.php';
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; 
$mail->Host = "localhost";
$mail->Port = 465; 
$mail->IsHTML(true);
$mail->Username = "abc@def.com";
$mail->Password = "xxx";
$mail->SetFrom("abc@def.com");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("uvw@xyz.com");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}

我发现了问题所在:从本质上讲,我只需要用$mail->isMail();替换$mail->isSMTP();,它就成功了——只是让其他人知道他们是否有同样的问题!

如果您提供的信息不正确,我深表歉意。但是,您应该确保服务器的smtp端口没有使用25

我也有同样的问题我尝试使用端口465的SSL,然后它说服务不可用然后我尝试这件事,它解决了我的问题希望它也能解决你的问题1( 确保使用$mail->IsSMTP((;用于身份验证。Ismail仅适用于具有邮件功能的同一服务器

2( 这东西解决了我的问题$mail->SMTPSecure="tsl";$mail->端口=587;

我加上这两行,现在电子邮件发送完全正常早些时候我遇到了这个错误SMTP连接((失败。https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting但以上的事情解决了我的问题希望对你有用谢谢

在使用Gmail的SMTP服务器发送电子邮件之前,您需要在谷歌帐户安全设置下进行一些安全和权限级别设置。

  1. 更改

$mail->host=";localhost";;

$mail->主机=";smtp.gmail.com";;

使用真实的电子邮件发送和接收"确保密码">

  1. 更改

$mail->SMTPSecure="ssl";

$mail->SMTPSecure="tls";

//tls for localhost and ssl for host server 'onligne'

可能对你有用:(

最新更新