Cant send emails via Gmail SMTP, Timeout error

postcd

Well-Known Member
Oct 22, 2010
717
19
68
Hello,

i have an professional Wordpress plugin, MailPoet and it can send email via SMTP instead PHP mail.

When i try to connect gmail i get:

[23-Jun-2015 10:02:39 UTC] PHP Warning: fsockopen() [<a href='function.fsockopen'>function.fsockopen</a>]: unable to connect to ssl://smtp.gmail.com:443 (Connection timed out) in /home/username/public_html/wp-content/plugins/wysija-newsletters/inc/phpmailer/class.smtp.php on line 123
[23-Jun-2015 10:02:53 UTC] ERROR PostmanWpMail: Exception code=403 message=Error calling POST https://www.googleapis.com/gmail/v1/users/me/messages/send: (403) Access Not Configured. The API (Gmail API) is not enabled for your project. Please use the Google Developers Console to update your configuration.
# telnet smtp.gmail.com 465
Trying 64.233.177.108...
Connected to smtp.gmail.com.
Escape character is '^]'.
Connection closed by foreign host.
# traceroute 64.233.177.108
traceroute to 64.233.177.108 (64.233.177.108), 30 hops max, 60 byte packets
send: Operation not permitted
Which Gmail SMTP details i used:
smtp.gmail.com
[email protected]
TLS/SSL
25/465
all these tried.

im using CSF and i made sure that 465 and 25 is withing allowed outgoing ports.

# netstat -tulnp | grep 465
tcp 0 0 0.0.0.0:465 0.0.0.0:* LISTEN 3490/exim
tcp 0 0 :::465 :::* LISTEN 3490/exim
"php_openssl" appears to be enabled

Please how to fix it so im allowed to connect external SMTP like Gmail? Can you advice which WHM server config i need to check? cpanel support ticket: 6730293

Thank you
 
Last edited:

postcd

Well-Known Member
Oct 22, 2010
717
19
68
Thanks but it is NOT cause of the problem.
unable to connect to ssl://smtp.gmail.com:465
unable to connect to smtp.gmail.com:25
unable to connect to smtp.gmail.com:465
unable to connect to smtp.gmail.com:587
i tried various ports. it just do not connect as mentioned above
unable to connect to ssl://smtp.gmail.com:465 (Connection timed out)
 
Last edited:

postcd

Well-Known Member
Oct 22, 2010
717
19
68
The cause is probably one of these three things?

1)
In Config server firewall configuration, there is section "IPv4 Port Settings" & "IPv6 Port Settings", i think it may be needed to add SMTP ports 25,465,587 into all TCP_OUT UDP_OUT variables in both above mentioned sections.
Then in same configuration CSF file, find section "SMTP Settings", set "SMTP_BLOCK =" to 0 or whitelist some cpanel users in variable "SMTP_ALLOWUSER ="
Save config and restart csf, lfd.
After that when logging via SSH to an cpanel account which i whitelisted (su - cpanelname), i see this:
# telnet smtp.gmail.com 465
Trying 74.125.21.108...
Connected to smtp.gmail.com.
Escape character is '^]'.
but still my .php mailer says: "SMTP Error: Could not authenticate. | SMTP Error: Could not connect to SMTP host."

2) from WHM, check Home »Server Configuration »Tweak Settings
- Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak) [?]
(Enabling this feature will redirect outgoing SMTP connections to the local mail server. root, exim, and mailman are still allowed to make direct connections.)

3) try to add gmail smtp IP (do command: telnet smtp.gmail.com 465) into config server firewall whitelist and ignore list?
 
  • Like
Reactions: ryborg

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,211
363
Hello :)

Has modifying any of those settings made a difference in the behavior of your application?

Thank you.
 

ryborg

Registered
Sep 28, 2016
1
1
3
US
cPanel Access Level
Root Administrator
The cause is probably one of these three things?

1)
In Config server firewall configuration, there is section "IPv4 Port Settings" & "IPv6 Port Settings", i think it may be needed to add SMTP ports 25,465,587 into all TCP_OUT UDP_OUT variables in both above mentioned sections.
Then in same configuration CSF file, find section "SMTP Settings", set "SMTP_BLOCK =" to 0 or whitelist some cpanel users in variable "SMTP_ALLOWUSER ="
Save config and restart csf, lfd.
After that when logging via SSH to an cpanel account which i whitelisted (su - cpanelname), i see this:

but still my .php mailer says: "SMTP Error: Could not authenticate. | SMTP Error: Could not connect to SMTP host."

2) from WHM, check Home »Server Configuration »Tweak Settings
- Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak) [?]
(Enabling this feature will redirect outgoing SMTP connections to the local mail server. root, exim, and mailman are still allowed to make direct connections.)

3) try to add gmail smtp IP (do command: telnet smtp.gmail.com 465) into config server firewall whitelist and ignore list?
I know this thread is old but it really helped me out. In my case, step 2) was the root cause. After updating that in WHM, I also needed to go through some troubleshooting steps to allow less secure apps to send email through my gmail account. This basically got me where I needed to go. Thanks!
 
  • Like
Reactions: cPanelMichael