In my local environment on a mamp server I was successfully able to send mails using larvel. However, after moving to production server on Hostgator, I am unable to send mails. I keep getting the following exception:

Swift_TransportException
Connection could not be established with host smtp.gmail.com [Connection refused #111]

I am using my gmail credentials with smtp host as smtp.gmail.com and port as 587.

Update 1: I spoke to Hostgator (based on first comment) and they say that the port is already enabled, however, I still have the same problem.

Can anyone please throw some light as to what can be wrong here?

Thanks.

有帮助吗?

解决方案

If they were blocking the port you'd probably get a timeout. "Connection Refused" would be coming from Gmail's end. They may have blocked the Hostgator IP range, specially if it's a shared IP.

Try using Hostgator's own SMTP servers? They're a cPanel host, if I recall, so you should be able to just use localhost to send mail.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top