Home >Backend Development >PHP Tutorial >Why Does My PHPMailer Connection Fail on GoDaddy Linux Server with \'Connection Refused\'?
Connection Refused with SMTP in PHPMailer Using GoDaddy Linux Server
When switching from a Windows to a Linux server hosted by GoDaddy, many users have reported issues with PHPMailer functionality due to a connection refused error. This issue arises even when the PHPMailer settings that have been working previously.
The error message typically reads:
SMTP -> ERROR: Failed to connect to server: Connection refused (111)SMTP Connect() failed.
Despite verifying settings with GoDaddy and ensuring accuracy, the error persists. However, a solution that has worked for some users involves modifying the PHPMailer script as follows:
<code class="php">$mail2->Host = localhost; //$mail2->SMTPAuth = false; //$mail2->Username = '[email protected]'; //$mail2->Password = '*******'; //$mail2->SMTPSecure = 'tls'; //$mail2->Port = 465;</code>
By commenting out settings related to SMTP authentication, username, password, and port, and setting the Host to localhost, the PHPMailer functionality is restored. This suggests that there may be an issue with the server settings, potentially related to the Linux environment, that the tech support personnel may not be aware of. It is advisable to reach out to GoDaddy's support team for further clarification and assistance.
The above is the detailed content of Why Does My PHPMailer Connection Fail on GoDaddy Linux Server with 'Connection Refused'?. For more information, please follow other related articles on the PHP Chinese website!