当前位置:网站首页>Phpmailer reported an error: SMTP error: failed to connect to server: (0)

Phpmailer reported an error: SMTP error: failed to connect to server: (0)

2022-07-05 03:57:00 Summer is already slightly cool

One 、 explain

  • According to this article PHPMailer Use , Configured with $mail->Username,$mail->Password after , The execution error is as follows :
2021-09-01 12:22:37 SMTP ERROR: Failed to connect to server: (0)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Error

Two 、 solve

1、 Ignore ssl authentication ( My is for this reason )

  • stay $mail = new PHPMailer(); Add the following code after
//  Instantiation PHPMailer Core class 
$mail = new PHPMailer(); 

$mail->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    )
);

...

2、 Set the port to bit 25 , Don't use SSL,465( Other possible reasons )

  • hold
//  Set to use ssl Encrypted login authentication 
$mail->SMTPSecure = 'ssl';
//  Set up ssl Connect smtp The remote server port number of the server 
$mail->Port = 465;
  • Change it to
$mail->Port = 25;

3、 ... and 、 His shan zhishi

原网站

版权声明
本文为[Summer is already slightly cool]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140717516135.html