Reputation: 189
When I try to send an email from my laravel site I get this error
Swift_TransportException in StreamBuffer.php line 268: Connection could not be established with host lin01.hkdns.co.za [ #0]
all my details is right. my env
MAIL_DRIVER=smtp
MAIL_HOST=lin01.hkdns.co.za
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl
In my mail.php
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
'name' => env('MAIL_FROM_NAME', 'Info'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
Did I miss something or is this a problem on my server?
Upvotes: 1
Views: 7365
Reputation: 2398
Sometime it's possible to be "cache" in the laravel.
Use this command and try again:
php artisan config:clear
If not work, try to restart you xampp.
Another option to check if the problem is with your host or your configuration is to use a Gmail server to send a test email.
Puts this in your .env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=apppassword
MAIL_ENCRYPTION=tls
Create or use any gmail account and enable the less secure apps more information here
first login to your gmail account and under My account > Sign In And Security > Sign In to google, enable two step verification, then you can generate app password, and you can use that app password in .env file.
Your .env file will then look something like this
MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=apppassword
MAIL_ENCRYPTION=tls
Don't forget to run
php artisan config:cache
after you make changes in your .env file (or restart your server).
Source here
Upvotes: 3