When attempting to send an email with remote SMTP authentication in PHP, the connections only occur on the localhost. The PHP script will also report authentication failed.
Often the websites or PHP scripts will be configured to SMTP authenticate using a remote SMTP server. However, cPanel has a setting to require all SMTP connections to use the localhost.
Disable SMTP restrictions in WHM.
Related documentation: https://docs.cpanel.net/whm/security-center/smtp-restrictions/
1. Login to WHM
2. Navigate to interface WHM Home > Security Center > SMTP Restrictions
3. If the protection is enabled, click the "Disable" button