# Error 110 smtp help

**URL:** <https://forum.infinityfree.com/t/error-110-smtp-help/68830>\
**Category:** Hosting Support\
**Created:** [November 26, 2022, 12:06pm UTC](https://forum.infinityfree.com/t/error-110-smtp-help/68830 "2022-11-26T12:06:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon99816020](https://forum.infinityfree.com/letter_avatar/anon99816020/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon99816020](https://forum.infinityfree.com/u/anon99816020)\
**Post date:** [November 26, 2022, 12:06pm UTC](https://forum.infinityfree.com/t/error-110-smtp-help/68830/1 "2022-11-26T12:06:53Z")

</div>

Continuing the discussion from [Unable to connect to SMTP server](https://forum.infinityfree.com/t/unable-to-connect-to-smtp-server/35288):

### 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

```auto
<?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= 'user@gmail.com';

$mail->Password = 'xxxxxx';

                   

$mail->SMTPSecure = 'tls';        

$mail->port = '587';      

$mail->setFrom("user@gmail.com)");

$mail->addAddress('user@gmail.com'); // 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();

?>

```

---

<div class="post-metadata">

**Author:** ![wackyblackie](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/wackyblackie/32/43350_2.png) [@wackyblackie](https://forum.infinityfree.com/u/wackyblackie)\
**Post date:** [November 26, 2022, 12:21pm UTC](https://forum.infinityfree.com/t/error-110-smtp-help/68830/2 "2022-11-26T12:21:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anon99816020](https://forum.infinityfree.com/letter_avatar/anon99816020/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon99816020](https://forum.infinityfree.com/u/anon99816020)\
**Post date:** [November 27, 2022, 1:45am UTC](https://forum.infinityfree.com/t/error-110-smtp-help/68830/3 "2022-11-27T01:45:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anon99816020](https://forum.infinityfree.com/letter_avatar/anon99816020/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon99816020](https://forum.infinityfree.com/u/anon99816020)\
**Post date:** [November 27, 2022, 1:47am UTC](https://forum.infinityfree.com/t/error-110-smtp-help/68830/4 "2022-11-27T01:47:46Z")

</div>

its working on locally but when I published it online it doesn’t work T\_T

---

<div class="post-metadata">

**Author:** ![Oxy](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/oxy/32/37989_2.png) [@Oxy](https://forum.infinityfree.com/u/Oxy)\
**Post date:** [November 27, 2022, 11:19am UTC](https://forum.infinityfree.com/t/error-110-smtp-help/68830/5 "2022-11-27T11:19:53Z")

</div>

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).

* * *

> **[Troubleshooting](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting)**
>
> The classic email sending library for PHP. Contribute to PHPMailer/PHPMailer development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![KangJL](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/kangjl/32/12130_2.png) [@KangJL](https://forum.infinityfree.com/u/KangJL)\
**Post date:** [November 27, 2022, 11:26am UTC](https://forum.infinityfree.com/t/error-110-smtp-help/68830/6 "2022-11-27T11:26:15Z")

</div>

> [@anon99816020](#):
>
> ```auto
> require('includes/PHPMailer.php');
> 
> require('includes/Exception.php');
> 
> require('includes/SMTP.php');
> 
> ```

Take note `includes` folder is blocked.

> [@Redirected to InfinityFree 403 Forbidden page](https://forum.infinityfree.com/t/redirected-to-infinityfree-403-forbidden-page/58664/1):
>
> ### The includes folder
> 
> For security reasons, all files in a folder `includes` are blocked. This includes URLs like [http://example.com/includes/function.php](http://example.com/includes/function.php) or [http://example.com/includes/pages/product.php](http://example.com/includes/pages/product.php).
> 
> The idea behind this is that `includes` means that the folder contains scripts meant to be loaded into other scripts with PHP [include](https://www.php.net/manual/en/function.include.php) (or [require](https://www.php.net/manual/en/function.require.php)). Scripts like that are generally not meant to be accessed directly.
> 
> The fix for this is simple: do not use the folder name `includes` for anything that’s supposed to be accessed by browser. Instead, put such pages in a folder `pages`, `functions`, `actions` or a folder with any other name.

---

<div class="post-metadata">

**Author:** ![Admin](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/admin/32/36437_2.png) [@Admin](https://forum.infinityfree.com/u/Admin)\
**Post date:** [November 27, 2022, 11:42am UTC](https://forum.infinityfree.com/t/error-110-smtp-help/68830/7 "2022-11-27T11:42:28Z")

</div>

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

> [@anon99816020](#):
>
> `$mail->port = '587'; `

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.

> [@KangJL](#):
>
> Take note `includes` folder is blocked.

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.

---

<div class="post-metadata">

**Author:** ![anon99816020](https://forum.infinityfree.com/letter_avatar/anon99816020/32/5_5575768a8748004e209b776fc1b2916d.png) [@anon99816020](https://forum.infinityfree.com/u/anon99816020)\
**Post date:** [November 28, 2022, 8:13am UTC](https://forum.infinityfree.com/t/error-110-smtp-help/68830/8 "2022-11-28T08:13:15Z")

</div>

It’s already fixed 🙂 , 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:🔥🔥

---

<div class="post-metadata">

**Author:** ![system](https://infinityfree-forum-uploads.s3.dualstack.eu-central-1.amazonaws.com/original/3X/b/0/b024fd3fa88bae093c9576e55c2c94e33f890206.svg) [@system](https://forum.infinityfree.com/u/system)\
**Post date:** [December 5, 2022, 8:13am UTC](https://forum.infinityfree.com/t/error-110-smtp-help/68830/9 "2022-12-05T08:13:39Z")

</div>

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