stmp php电子邮件-SMTP错误:无法连接到服务器:(0)SMTP connect()失败

stmp php电子邮件-SMTP错误:无法连接到服务器:(0)SMTP connect()失败,php,email,smtp,Php,Email,Smtp,我与phpMailer有问题,我无法发送任何电子邮件,它会给我以下错误: 2020-03-14 21:58:06 SMTP ERROR: Failed to connect to server: (0) SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent. Error: SMTP connect() failed.

我与phpMailer有问题,我无法发送任何电子邮件,它会给我以下错误:

2020-03-14 21:58:06 SMTP ERROR: Failed to connect to server: (0)
    SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
    Message could not be sent. Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
我用于发送电子邮件的代码:

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
$mail = new PHPMailer();
$mail->SMTPDebug = SMTP::DEBUG_SERVER;                     
$mail->IsSMTP(true);
$mail->Host = 'example.com';
$mail->SMTPAuth= true;
$mail->Username='test@example.com';
$mail->Password='password';
$mail->Port = 465; 
$mail->SMTPDebug = 2; 
$mail->SMTPSecure = 'ssl';
$mail->SetFrom('test@example.com', 'Example Account');
$mail->AddAddress(`receiver@gmail.com', 'Rec Eiver');
$mail->Subject = 'Subject';
$mail->Subject = "Here is the subject";
$mail->Body    = "This is the HTML message body <b>in bold!</b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail    clients";
if(!$mail->Send()) {
    echo "Message could not be sent.  Error: {$mail->ErrorInfo}";
} else {
    echo 'Message has been sent';
}
使用PHPMailer\PHPMailer\PHPMailer;
使用PHPMailer\PHPMailer\SMTP;
使用PHPMailer\PHPMailer\Exception;
需要“vendor/autoload.php”;
$mail=new PHPMailer();
$mail->SMTPDebug=SMTP::调试服务器;
$mail->IsSMTP(正确);
$mail->Host='example.com';
$mail->SMTPAuth=true;
$mail->Username=test@example.com';
$mail->Password='Password';
$mail->Port=465;
$mail->SMTPDebug=2;
$mail->SMTPSecure='ssl';
$mail->SetFrom('test@example.com“,”示例账户“);
$mail->AddAddress(`receiver@gmail.com","Rec Eiver",;
$mail->Subject='Subject';
$mail->Subject=“主题在这里”;
$mail->Body=“这是以粗体显示的HTML邮件正文!”;
$mail->AltBody=“这是非HTML邮件客户端的纯文本正文”;
如果(!$mail->Send()){
echo“无法发送邮件。错误:{$mail->ErrorInfo}”;
}否则{
回音“消息已发送”;
}

我用的是GoDaddy CPanel

我认为你的代码是正确的

尝试创建帐户邮件陷阱:
并使用mailtrap配置进行测试。

我希望这些不是真实的凭据:)请在
mg store.net
上更改您的密码,如果您提供了真实的凭据,请在
AddAddress
意外?@El_Vanja中打勾是错误的,但这不是问题…`SERVER->CLIENT:mywebsite ESMTP Exim 4.92#2 Sat,2020年3月14日15:44:23-0700 220我们不授权使用此系统传输未经请求的220和/或批量电子邮件。客户端->服务器:EHLO mywebsite服务器->客户端:mywebsite你好mywebsite[mywebsite_ip]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250-CHUNKING250-STARTTLS250-SMTPUTF8250帮助客户端->服务器:STARTTLS服务器->客户端:220 TLS继续SMTP错误:无法连接到SMTP主机。客户端->服务器:退出SMTP连接()失败`我需要用我的电子邮件。