Search code examples
laravellaravel-5smtpsendmail

Swift_TransportException Connection could not be established with host mywebsite.com


Getting the titled issue with a contact form with my site and sending to a SSL email account on a cpanel godaddy server with Laravel. Has anyone has similar?

Here are the credentials im using:

MAIL_DRIVER=smtp
MAIL_HOST=mywebsite.com
MAIL_PORT=465
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=ssl

Solution

  • For sending emails natively from your own server similar to mail() function use sendmail as driver

    MAIL_DRIVER=sendmail
    MAIL_HOST=mywebsite.com
    MAIL_PORT=465
    MAIL_USERNAME=
    MAIL_PASSWORD=
    MAIL_ENCRYPTION=ssl
    

    OR only use mail

    MAIL_DRIVER=mail
    MAIL_HOST=mywebsite.com
    MAIL_PORT=465
    MAIL_USERNAME=
    MAIL_PASSWORD=
    MAIL_ENCRYPTION=ssl
    

    Make sure to clear config cache.