Showing results for 
Show  only  | Search instead for 
Did you mean: 

PHPMailer fails to send email by external smtp server

I use following to send an email by phpmailer, but it fails. Error message is:  


2018-08-30 03:45:51 SMTP ERROR: Failed to connect to server: Connection refused (111)
SMTP connect() failed.


But it worked in other hosting from other provider. 


PHP code: 

$mail->SMTPDebug = 2; 
$mail->Host = ''; 
$mail->SMTPAuth = true; 
$mail->Username = '';
$mail->Password = 'mypassword';
$mail->SMTPSecure = 'ssl'; 
$mail->Port = 994; 




I searched posts here for whole day, then tried following code. It can work to send email to a email a/c, but while sending email to or email a/c, there is no error from the code, but there is not email received. I appreciate if anyone would help.


$mail->Host = 'localhost';
$mail->SMTPAuth = false;
$mail->Username = "";
$mail->Password = "";
$mail->SMTPSecure = false;
$mail->Port = 25;