phpmailer could not authenticate on my server

leonep

Well-Known Member
Nov 18, 2014
249
24
68
Pescara
cPanel Access Level
Root Administrator
Hello,
i have problem with a cms plugin in wordpress. it require smtp to send.
i setup an email account on my server but it not works.the plugin uses phpmailer.
so i setup a folder with fresh phpmailer from github but i got the same error:

# php test_smtp.php
2023-03-20 16:43:02 Connection: opening to ssl://xxxxx.xxxxx.xxx:465, timeout=300, options=array()
2023-03-20 16:43:02 Connection: opened
2023-03-20 16:43:02 SERVER -> CLIENT: 220-xxxxx.xxxxx.xxx ESMTP Exim 4.96 #2 Mon, 20 Mar 2023 17:43:02 +0100
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
2023-03-20 16:43:02 CLIENT -> SERVER: EHLO xxxxx.xxxxx.xxx
2023-03-20 16:43:02 SERVER -> CLIENT: 250-xxxxx.xxxxx.xxx Hello xxxxx.xxxxx.xxx [xx.xx.xx.xx]
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-PIPECONNECT
250 HELP
2023-03-20 16:43:02 SMTP Error: Could not authenticate.
2023-03-20 16:43:02 CLIENT -> SERVER: QUIT
2023-03-20 16:43:02 SERVER -> CLIENT: 221 xxxxx.xxxxx.xxx closing connection
2023-03-20 16:43:02 Connection: closed
2023-03-20 16:43:02 SMTP Error: Could not authenticate.

of course username and password are correct (tested on webmail)
i try to disable firewall but no success.

setup is:
$mail->SMTPDebug = 3;
$mail->isSMTP();
$mail->Host = 'hostname';
$mail->SMTPAuth = true;
$mail->Username = 'email';
$mail->Password = 'zzzzzzzzzz';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$mail->Port = 465;

exim is working good with email clients like outlook or mail so i do not understand. what can i check ?

thanks
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
17,468
2,842
363
cPanel Access Level
Root Administrator
Hey there! Our support for the PHP mailer tools is very limited. Can you try working through the example script here and seeing if that allows you to connect properly?


If not, I would recommend checking /var/log/maillog to see if that gives you more details about the failed authentication.
 

leonep

Well-Known Member
Nov 18, 2014
249
24
68
Pescara
cPanel Access Level
Root Administrator
thanks @cPRex ,
I actually already set debugging to verbose
what worries me is why if I set SMTPauth to false it works ,while if I set it to true it doesn't work (authentication error)
it seems strange to me that any php page can submit without authentication
I would like to know if this is normal behavior or if there is something wrong with my whm/cpanel security settings.