Search code examples
phplaravelsmtpgmaillaravel-5.6

Connection could not be established with host smtp.gmail.com [Connection refused #111] in laravel 5.6 email send


Email Sending failed from cpnel but it works fine in my localhost.

Here is my email configuration in .env file.

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=ssl

It works fine in localhost but not working in cpanel. In cpanel it shows

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

How do i solve this?


Solution

  • Problem Solved. I made the change two things here MAIL_DRIVER and MAIL_PORT.

    MAIL_DRIVER=sendmail
    MAIL_PORT=587
    

    So, my full code is:

    MAIL_DRIVER=sendmail
    MAIL_HOST=smtp.gmail.com
    MAIL_PORT=587
    [email protected]
    MAIL_PASSWORD=mypassword
    MAIL_ENCRYPTION=ssl
    

    It works fine