Error 110 smtp help

Continuing the discussion from Unable to connect to SMTP server:

Username (e.g. epiz_XXX) or Website URL

(please specify the website or account you are asking about)

Error Message

error 110 can’t connect to host

Other Information

<?php
//my code
//include phpmailers files

require('includes/PHPMailer.php');

require('includes/Exception.php');

require('includes/SMTP.php');



use PHPMailer\PHPMailer\SMTP;

use PHPMailer\PHPMailer\Exception;

use PHPMailer\PHPMailer\PHPmailer;

$mail = new PHPmailer();
$mail->SMTPDebug = 3;

$mail->isSMTP();

$mail->Mailer= "smtp";

$mail->Host = 'smtp.gmail.com';  

$mail->SMTPAuth = true;  


$mail->Username= '[email protected]';


$mail->Password = 'xxxxxx';

                   

$mail->SMTPSecure = 'tls';        

$mail->port = '587';      

$mail->setFrom("[email protected])");

$mail->addAddress('[email protected]');               // Name is optional                      

$mail->isHTML(true);                                  // Set email format to HTML

 

$mail->Subject = 'text ';

$mail->Body    = 'This is the HTML message body <b>HELLO WORLD</b>';

$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->send()) {

echo 'Message could not be sent.';

echo 'Mailer Error: ' . $mail->ErrorInfo;

} else {

echo 'Message has been sent';

}

$mail->smtpClose();

?>

Can you change the Debug constant to 4 instead of 3? Then, share the logs here, but be sure to hide your email and password, as those will be displayed with the most verbose logging level.

5 Likes

I’ve already changed it to debug 4 nothing changes same errors displayed! is there any chance that my host is wrong? Or ports or whatsoever

its working on locally but when I published it online it doesn’t work T_T

Share with us your configuration (conn data) - hide sensitive data.
Which mail server do you want to connect to (host)?


Error: Failed to connect to server: Connection timed out (110)
SMTP Error: Could not connect to SMTP host.

It means the mail server can not be reached ( usually because your hosting
provider is blocking the port with a firewall).


5 Likes

Take note includes folder is blocked.

1 Like

Your settings look fine at first sight, but there are a few things you could try:

I believe the setting is Port, not port. Also, the port number is supposed to be a number, not a string. So could you please try this instead?

$mail->Port = 587;

If this still doesn’t work, you could also try port 465 with ssl security instead.

For web access only. Files stored in an includes folder can be loaded into other scripts without any problems, exactly like what happens here.

Please don’t start moving PHPMailer internals around, that’s a great way to create even more problems.

6 Likes

It’s already fixed :slight_smile: , I’ve Just changed the host value to “tls://smtp.gmail.com:587” and erase $mail->Port
I don’t know if Is it okay to set it that way but it worked. Thanks a lot guys​:fire::fire::fire:

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.