I’m having trouble with my email system on my cPanel-hosted site. It’s set up to use Gmail’s SMTP server, and it works fine on my computer. But when I try it on the live site, it keeps timing out. Here’s the error I’m getting:
Error: Unable to connect to smtp.gmail.com:587 (Connection timed out)
MAIL_SETTINGS:
SERVER=smtp.gmail.com
PORT=587
[email protected]
PASS=MyAppPassword
SECURITY=tls
[email protected]
NAME=MyApp
I’ve double-checked all the settings, and they’re the same as my local setup. I’ve tried different ports too, but no luck. My site is on shared hosting with cPanel, using PHP 8.2 and Laravel 11. I’ve got 2FA turned on for my Google account.
I’m wondering if maybe the server is blocking Gmail SMTP connections. How can I confirm this? Are there other ways to test SMTP on shared hosting? Should I ask my host to unblock something?
I can’t access the server directly, just cPanel. Any ideas on how to fix this or what to try next?
I’ve encountered this issue before on shared hosting. It’s likely your host is blocking outgoing SMTP connections to Gmail. This is a common practice to prevent spam.
Contact your hosting provider’s support and ask them if they block SMTP connections to external services like Gmail. If they do, request that they whitelist Gmail’s SMTP servers for your account.
Alternatively, consider using your host’s built-in mail server, which is typically more reliable on shared hosting environments, or use a transactional email service like SendGrid or Mailgun. Make sure to update your configuration settings accordingly and test each change thoroughly.
yo, had the same prob. ur host prob blocks gmail smtp. try askin support to unblock it. or use their mail server instead - usually works better anyway. i switched to mailgun n it fixed everything. good luck man!
I’ve dealt with similar issues before, and it’s often related to server restrictions. Shared hosting providers frequently block outgoing SMTP connections to prevent spam abuse. Here’s what I’d suggest:
First, check if your host allows external SMTP. Some have specific policies against it. If they do allow it, you might need to request them to whitelist Gmail’s SMTP servers.
Have you tried using your hosting provider’s built-in mail server instead? It’s usually more reliable on shared hosting. You can find these settings in cPanel under ‘Email Accounts’.
Another option is to use a transactional email service like SendGrid or Mailgun. They often have better deliverability and are less likely to be blocked.
If you’re set on using Gmail, try port 465 with SSL instead of 587 with TLS. Some hosts block TLS connections but allow SSL.
Lastly, check your server’s firewall settings in cPanel if you have access. Sometimes, outgoing SMTP connections are blocked there.
Remember to test each change thoroughly. Good luck!