laravel5 and GoDaddy Exception when trying to send

2019-07-21 22:58发布

问题:

as the title says, when I'm trying to send a mail with Laravel 5 and with a shared host in GoDaddy I get the following error.

    Swift_TransportException in StreamBuffer.php line 265:
    Connection could not be established with host >localhost [php_network_getaddresses: 
    getaddrinfo failed: Name or service not known #0]

This is the configuration that I'm using:

'driver' => 'smtp',
'host' => 'localhost',
'port' => 587,
'from' => array('address' => 'mail@domain.com', 'name' => 'name'),
'encryption' => 'tls',
'username' => 'cpanel user name',
'password' => 'cpanel password',
'sendmail' => '/usr/lib/sendmail -t',
'pretend' => false,

As the support guy from GoDaddy told me, I use the host as "localhost" instead my domain name but still getting the exception.

Can anyone give me a hand with the correct configuration please?

回答1:

I had the same issue when I was using Godaddy web hosting and solved this by editing my .env file as,

MAIL_DRIVER=smtp
MAIL_HOST=XXXX.XXXX.in
MAIL_PORT=587
MAIL_USERNAME=dexxxxx
MAIL_PASSWORD=XXXXXXXX
MAIL_ENCRYPTION=tls

Where MAIL_HOST is your domain name from Godaddy, MAIL_USERNAME is your user name from Godaddy and MAIL_PASSWORD is your password from Godaddy.

I hope this may help you.