1
votes

Hi I have recently installed a fresh version of zizaco confide and it is not sending me an email confirmation, when I turn the require email settings off it works as normal. But if I leave on the email is not sent, but the user is written to the db and the page redirects to users/ with a whoops something went wrong page.

The below files are the only edits I have made thus far, I've tried three different fresh downloads using composer to download laravel via terminal and using the composer file in laravel to download confide as per the instructions on github

Hope someone can help

My compsoer.json file is as so:

 "zizaco/confide": "~4.0@dev"

My mail.php is as so:

<?php
  return array(

  'driver' => 'smtp',
  'host' => 'smtp.gmail.com',
  'port' => 587,
  'from' => array('address' => '****', 'name' => '******'),
  'encryption' => 'tls',
  'username' => '******',
  'password' => '*******',
  'sendmail' => '/usr/sbin/sendmail -bs',
   'pretend' => false,
  );

My auth.php is as so:

 <?php

      return array(
        'driver' => 'eloquent',
         'model' => 'User',
         'table' => 'users',
          'reminder' => array(
         'email' => 'emails.auth.reminder',
         'table' => 'password_reminders',
         'expire' => 60,
        ),
 );

and my App.php is as so:

 <?php

 return array(

'debug' => false,
'url' => 'http://itempus.dev',
'timezone' => 'GMT',
'locale' => 'en',
'fallback_locale' => 'en',
'key' => 'C6u09tcUUFS9JtVsHVW0av5IUdK3ogbG',
'cipher' => MCRYPT_RIJNDAEL_128,
'providers' => array(

    'Illuminate\Foundation\Providers\ArtisanServiceProvider',
    'Illuminate\Auth\AuthServiceProvider',
    'Illuminate\Cache\CacheServiceProvider',
    'Illuminate\Session\CommandsServiceProvider',
    'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
    'Illuminate\Routing\ControllerServiceProvider',
    'Illuminate\Cookie\CookieServiceProvider',
    'Illuminate\Database\DatabaseServiceProvider',
    'Illuminate\Encryption\EncryptionServiceProvider',
    'Illuminate\Filesystem\FilesystemServiceProvider',
    'Illuminate\Hashing\HashServiceProvider',
    'Illuminate\Html\HtmlServiceProvider',
    'Illuminate\Log\LogServiceProvider',
    'Illuminate\Mail\MailServiceProvider',
    'Illuminate\Database\MigrationServiceProvider',
    'Illuminate\Pagination\PaginationServiceProvider',
    'Illuminate\Queue\QueueServiceProvider',
    'Illuminate\Redis\RedisServiceProvider',
    'Illuminate\Remote\RemoteServiceProvider',
    'Illuminate\Auth\Reminders\ReminderServiceProvider',
    'Illuminate\Database\SeedServiceProvider',
    'Illuminate\Session\SessionServiceProvider',
    'Illuminate\Translation\TranslationServiceProvider',
    'Illuminate\Validation\ValidationServiceProvider',
    'Illuminate\View\ViewServiceProvider',
    'Illuminate\Workbench\WorkbenchServiceProvider',
    'Zizaco\Confide\ServiceProvider',

),
'manifest' => storage_path().'/meta',
'aliases' => array(

    'App'             => 'Illuminate\Support\Facades\App',
    'Artisan'         => 'Illuminate\Support\Facades\Artisan',
    'Auth'            => 'Illuminate\Support\Facades\Auth',
    'Blade'           => 'Illuminate\Support\Facades\Blade',
    'Cache'           => 'Illuminate\Support\Facades\Cache',
    'ClassLoader'     => 'Illuminate\Support\ClassLoader',
    'Config'          => 'Illuminate\Support\Facades\Config',
    'Controller'      => 'Illuminate\Routing\Controller',
    'Cookie'          => 'Illuminate\Support\Facades\Cookie',
    'Crypt'           => 'Illuminate\Support\Facades\Crypt',
    'DB'              => 'Illuminate\Support\Facades\DB',
    'Eloquent'        => 'Illuminate\Database\Eloquent\Model',
    'Event'           => 'Illuminate\Support\Facades\Event',
    'File'            => 'Illuminate\Support\Facades\File',
    'Form'            => 'Illuminate\Support\Facades\Form',
    'Hash'            => 'Illuminate\Support\Facades\Hash',
    'HTML'            => 'Illuminate\Support\Facades\HTML',
    'Input'           => 'Illuminate\Support\Facades\Input',
    'Lang'            => 'Illuminate\Support\Facades\Lang',
    'Log'             => 'Illuminate\Support\Facades\Log',
    'Mail'            => 'Illuminate\Support\Facades\Mail',
    'Paginator'       => 'Illuminate\Support\Facades\Paginator',
    'Password'        => 'Illuminate\Support\Facades\Password',
    'Queue'           => 'Illuminate\Support\Facades\Queue',
    'Redirect'        => 'Illuminate\Support\Facades\Redirect',
    'Redis'           => 'Illuminate\Support\Facades\Redis',
    'Request'         => 'Illuminate\Support\Facades\Request',
    'Response'        => 'Illuminate\Support\Facades\Response',
    'Route'           => 'Illuminate\Support\Facades\Route',
    'Schema'          => 'Illuminate\Support\Facades\Schema',
    'Seeder'          => 'Illuminate\Database\Seeder',
    'Session'         => 'Illuminate\Support\Facades\Session',
    'SoftDeletingTrait' => 'Illuminate\Database\Eloquent\SoftDeletingTrait',
    'SSH'             => 'Illuminate\Support\Facades\SSH',
    'Str'             => 'Illuminate\Support\Str',
    'URL'             => 'Illuminate\Support\Facades\URL',
    'Validator'       => 'Illuminate\Support\Facades\Validator',
    'View'            => 'Illuminate\Support\Facades\View',
    'Confide'         => 'Zizaco\Confide\Facade',


),

 );

User.php

 <?php

      use Zizaco\Confide\ConfideUser;
      use Zizaco\Confide\ConfideUserInterface;

      class User extends Eloquent implements ConfideUserInterface
           {
               use ConfideUser;
           }

Edit

User Controller Store Method :

  public function store()
      {
          $repo = App::make('UserRepository');
          $user = $repo->signup(Input::all());

          if ($user->id) {
                 if (Config::get('confide::email_account_confirmation')) {
                        Mail::send(
                            compact('user'),
                            function ($message) use ($user) {
                                $message
                                    ->to($user->email, $user->username)
                                    ->subject(Lang::get('confide::confide.email.account_confirmation.subject'));
                }
            );


        }

        return Redirect::action('UsersController@login')
            ->with('notice', Lang::get('confide::confide.alerts.account_created'));
    } else {
        $error = $user->errors()->all(':message');

        return Redirect::action('UsersController@create')
            ->withInput(Input::except('password'))
            ->with('error', $error);
    }
}

Error Log

 [2014-08-09 15:29:55] production.ERROR: exception 'ErrorException' with message 'Argument 2 passed to Illuminate\Mail\Mailer::send() must be of the type array, object given, called in /Applications/XAMPP/xamppfiles/htdocs/tempus2/bootstrap/compiled.php on line 3229 and defined'      in      /Applications/XAMPP/xamppfiles/htdocs/tempus2/vendor/laravel/framework/src/Illuminate/Mail/Mai     ler.php:133
 Stack trace:
      #0 /Applications/XAMPP/xamppfiles/htdocs/tempus2/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(133): Illuminate\Exception\Handler->handleError(4096, 'Argument 2 pass...', '/Applications/X...', 133, Array)
 #1 /Applications/XAMPP/xamppfiles/htdocs/tempus2/bootstrap/compiled.php(3229): Illuminate\Mail\Mailer->send(Array, Object(Closure))
 #2 /Applications/XAMPP/xamppfiles/htdocs/tempus2/app/controllers/UsersController.php(42): Illuminate\Support\Facades\Facade::__callStatic('send', Array)
 #3 /Applications/XAMPP/xamppfiles/htdocs/tempus2/app/controllers/UsersController.php(42): Illuminate\Support\Facades\Mail::send(Array, Object(Closure))
 #4 [internal function]: UsersController->store()
 #5 /Applications/XAMPP/xamppfiles/htdocs/tempus2/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(231): call_user_func_array(Array, Array)
 #6 /Applications/XAMPP/xamppfiles/htdocs/tempus2/bootstrap/compiled.php(5784): Illuminate\Routing\Controller->callAction('store', Array)
 #7 /Applications/XAMPP/xamppfiles/htdocs/tempus2/bootstrap/compiled.php(5772): Illuminate\Routing\ControllerDispatcher->call(Object(UsersController), Object(Illuminate\Routing\Route), 'store')
 #8 /Applications/XAMPP/xamppfiles/htdocs/tempus2/bootstrap/compiled.php(4971): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'UsersController', 'store')
 #9 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}()
 #10 /Applications/XAMPP/xamppfiles/htdocs/tempus2/bootstrap/compiled.php(5330): call_user_func_array(Object(Closure), Array)
 #11 /Applications/XAMPP/xamppfiles/htdocs/tempus2/bootstrap/compiled.php(4996): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
 #12 /Applications/XAMPP/xamppfiles/htdocs/tempus2/bootstrap/compiled.php(4984): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
 #13 /Applications/XAMPP/xamppfiles/htdocs/tempus2/bootstrap/compiled.php(717): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
 #14 /Applications/XAMPP/xamppfiles/htdocs/tempus2/bootstrap/compiled.php(698): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
 #15 /Applications/XAMPP/xamppfiles/htdocs/tempus2/bootstrap/compiled.php(7706): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
 #16 /Applications/XAMPP/xamppfiles/htdocs/tempus2/bootstrap/compiled.php(8309): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
 #17 /Applications/XAMPP/xamppfiles/htdocs/tempus2/bootstrap/compiled.php(8256): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
 #18 /Applications/XAMPP/xamppfiles/htdocs/tempus2/bootstrap/compiled.php(10895): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
 #19 /Applications/XAMPP/xamppfiles/htdocs/tempus2/bootstrap/compiled.php(659): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
 #20 /Applications/XAMPP/xamppfiles/htdocs/tempus2/public/index.php(49): Illuminate\Foundation\Application->run()
 #21 {main} [] []
2

2 Answers

1
votes

As per advice from uiroshan User Controller store function should be changed to the following:

public function store()
{
    $repo = App::make('UserRepository');
    $user = $repo->signup(Input::all());

    if ($user->id) {
        {
    Mail::send(
        Config::get('confide::email_account_confirmation'),
        compact('user'),
        function ($message) use ($user) {
            $message
                ->to($user->email, $user->username)
                ->subject(Lang::get('confide::confide.email.account_confirmation.subject'));
        }
            );
        }

        return Redirect::action('UsersController@login')
            ->with('notice', Lang::get('confide::confide.alerts.account_created'));
    } else {
        $error = $user->errors()->all(':message');

        return Redirect::action('UsersController@create')
            ->withInput(Input::except('password'))
            ->with('error', $error);
    }
}
0
votes

I am having the same problem. As per my observations, this is nothing to do with configuration setup. If we change UsersController's store() method to send the mail immediately (without queueing) application will send the mail to registered user without any problem.

    if ($user->id) {
        Mail::send(
            Config::get('confide::email_account_confirmation'),
            compact('user'),
            function ($message) use ($user) {
                $message
                    ->to($user->email, $user->username)
                    ->subject(Lang::get('confide::confide.email.account_confirmation.subject'));
            }
        );

This seems to be a problem with either generated code or the laravel sync queues. But I think this will help you to avoid problem you are having.

Update

I have extracted the following line from your error logs. This is most important line describing your error.

'Argument 2 passed to Illuminate\Mail\Mailer::send() must be of the type array, object given,

so I think the problem describing in this log is, you need to pass argument as per the method signature. But in your question's example code missing the first argument. (i.e. You are missing Config::get('confide::email_account_confirmation'), in your send method). Actual send method signature is look like below.

public function send($view, array $data, $callback)

Try modifying the code as per my example code above. Hope it will work.