Support the ongoing development of Laravel.io →
Configuration Mail Installation

I'm trying to send an email using the standard email feature in Laravel 5.

I'm using smtp from google to send mails. When working local the email sends without a problem. But when I'm trying to do the same on my hosting (one.com) I get the following error.

Swift_TransportException in StreamBuffer.php line 265:
Connection could not be established with host smtp.gmail.com [Connection timed out #110]
in StreamBuffer.php line 265
at Swift_Transport_StreamBuffer->_establishSocketConnection() in StreamBuffer.php line 62
at Swift_Transport_StreamBuffer->initialize(array('protocol' => 'tcp', 'host' => 'smtp.gmail.com', 'port' => '587', 'timeout'     => '30', 'blocking' => '1', 'tls'     => true, 'type' => '1')) in AbstractSmtpTransport.php line 113
at Swift_Transport_AbstractSmtpTransport->start() in Mailer.php line 79

my .env file

APP_ENV=local
APP_DEBUG=true
APP_KEY=****

DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=localhost
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=****@gmail.com
MAIL_PASSWORD=****
MAIL_ENCRYPTION=tls

My route to test the mail

Route::get('mail', function()
{
    Mail::send('mail.contact', [], function ($message)
    {
        $message->to('****@gmail.com', 'Test')->subject('Welcome!');
    });
});
Last updated 3 years ago.
0

has your hosting provider blocked outgoing connections to specific ips ? if you have ssh access check if you can ping smtp.gmail.com

0

Sign in to participate in this thread!

PHPverse

Your banner here too?

ViktorDB viktordb Joined 30 Dec 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.