Laravel, sending a SMTP gmail email end in the following error: Maximum execution time of 30 seconds exceeded

StackOverflow https://stackoverflow.com/questions/22634594

Frage

I am following a tutorial on sending emails with Laravel and I don't know what I am doing wrong.

Here's the flow:

  1. I add a route to the user's future dashboard page:

    Route::get('/dashboard', array( 'as' => 'dashboard', 'uses' => 'UsersController@dashboard' ));

  2. Now inside the UsersController, when I visit the 'dashboard' path, an email will be sent:

    public function dashboard () {

    Mail::send('emails.auth.test', $data, function($message) {
        $message->to('avalidemail@gmail.com', 'John Doe')->subject('Welcome!');
    });
    
    return  View::make('dashboard'); 
    

    }

  3. Lets get to the config - config/mail.php

Here are my settings:

'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 465,
'from' => array('address' => 'myemailaddress@gmail.com', 'name' => 'Auth'),
'encryption' => 'ssl',
'username' => 'myemailaddress@gmail.com',
'password' => 'myvalidpass',
'pretend' => false

What am I doing wrong?

I am on WAMP.

I have setup a virtual host - I reach my site like this: laravel.dev

Do I have to setup something in Wamp?

I've looked trhough my php.ini and found:

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

Tried to put here the gmail credentials - still did not work.

Do I have to enable anything in my gmail account?

Finaly, the error I get, when I visit - localhost.dev/dashboard:

Symfony \ Component \ Debug \ Exception \ FatalErrorException

Maximum execution time of 30 seconds exceeded

Any ideas?

Ty!

War es hilfreich?

Lösung

This might have just been a typo in your question but you mention configuring your virtual host to respond to "laravel.dev" but then accessing through "localhost.dev/dashboard". What happens if you try to access through "laravel.dev/dashboard"? I have a Laravel application sending through gmail using very similar settings to yours, so it must be something unrelated to those smtp settings that is causing you problems..

You could also try commenting out the Mail::send call and make sure that you are able to visit this route without any issues, and confirm it is the mail call that is your source of problem. Also, perhaps this was only a snippet of your dashboard function, but you are referencing a $data variable this isn't defined elsewhere. This shouldn't cause the error you're seeing though, it should be a different error.. the error you're seeing sounds more like some kind of routing loop or something..

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top