Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

orverduzco's avatar

How to configure email sending over SMTP on Hostgator shared hosting?

Hi,

I'm trying to send emails using SMTP on an installation of Laravel on Hostgator's shared hosting, but I'm getting this error:

(1/1) Swift_TransportException Connection could not be established with host smtp.mailtrap.io [Connection refused #111]

Looks like it's something related to my config/mail.php file... Is there any configuration example that I could use? BTW, the email hosting is provided by Hostgator.

Thanks in advance.

0 likes
4 replies
liudaxingtx's avatar

use ssl instead of tls. And for the host, use the hostgator server name, instead of your domain.com. It works for me.

jitesht's avatar

@liudaxingtx I also faced the same issue with Laravel Hostgator. My SMTP details working perfectly PHPMailer library. I don't know why it creating issue in Laravel.What do you mean by hostgator server name here?

CodeNathan's avatar

check your .env file and ensure the settings are there as follows

MAIL_DRIVER=smtp
MAIL_HOST=your_host
MAIL_PORT=465
MAIL_USERNAME=your_email
MAIL_PASSWORD=your_password
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=your_email
jalexmelendez's avatar

I fixed it, on the config/mail.php under the smtp option add this line: 'local_domain' => env('MAIL_EHLO_DOMAIN'),

and on the .env file add this config: MAIL_MAILER=smtp MAIL_HOST=NAMESERVER.hostgator.mx MAIL_PORT=465 [email protected] MAIL_PASSWORD=PASSWORD MAIL_ENCRYPTION=ssl MAIL_EHLO_DOMAIN=example.com MAIL_FROM_ADDRESS="[email protected]" MAIL_FROM_NAME="${APP_NAME}"

And here's an article on Medium i wrote about https://medium.com/@alexmlndz1u/how-to-use-hostgator-smtp-to-send-emails-in-laravel-or-any-backend-b1568c283790

Please or to participate in this conversation.