Laravel Mail Timeout Issue in Production (mail.privateemail.com on DigitalOcean via Forge)
I'm running a Laravel application that I deployed to a DigitalOcean droplet using Laravel Forge. Email works perfectly in my local environment, but in production, I'm encountering a connection timeout when trying to send emails.
Here are my mail settings from the .env file on the production server:
MAIL_MAILER=smtp
MAIL_HOST=mail.privateemail.com
MAIL_PORT=587
MAIL_USERNAME=[email protected]
MAIL_PASSWORD=********
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=[email protected]
MAIL_FROM_NAME="${APP_NAME}"
the error log
production.ERROR: Connection could not be established with host "mail.privateemail.com:587":
stream_socket_client(): Unable to connect to mail.privateemail.com:587 (Connection timed out)
What I’ve tried:
Confirmed that the same settings work on my local machine.
Verified the credentials and mail host are correct.
Allowed outbound connections on port 587 from the Forge Network tab (firewall settings).
Tested other ports like 465 (ssl) but still no success.
Question:
Why is this connection timing out only in production?
Is there something specific I should check on DigitalOcean, Laravel Forge, or with privateemail.com?