您好我最近安装了一个新版本的zizaco confide并且它没有向我发送电子邮件确认,当我关闭require电子邮件设置时,它正常工作。但是,如果我留下电子邮件没有发送,但用户被写入数据库,页面重定向到用户/哎呀有些事情出错了。
以下文件是我迄今为止所做的唯一编辑,我尝试了三种不同的全新下载,使用编辑器通过终端下载laravel并使用laravel中的composer文件按照{{上的说明下载信息3}}
希望有人可以提供帮助
我的compsoer.json文件是这样的:
"zizaco/confide": "~4.0@dev"
我的mail.php如此:
<?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,
);
我的auth.php如此:
<?php
return array(
'driver' => 'eloquent',
'model' => 'User',
'table' => 'users',
'reminder' => array(
'email' => 'emails.auth.reminder',
'table' => 'password_reminders',
'expire' => 60,
),
);
和我的App.php一样:
<?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;
}
用户控制器存储方法:
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);
}
}
[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} [] []
答案 0 :(得分:1)
根据uiroshan用户控制器存储功能的建议,应更改为以下内容:
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);
}
}
答案 1 :(得分:0)
我遇到了同样的问题。根据我的观察,这与配置设置无关。如果我们更改UsersController
store()
方法以立即发送邮件(无需排队),应用程序会将邮件发送给注册用户,而不会出现任何问题。
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'));
}
);
这似乎是生成代码或laravel sync
队列的问题。但我认为这可以帮助您避免遇到问题。
<强>更新强>
我从错误日志中提取了以下行。这是描述错误的最重要的一行。
&#39;参数2传递给Illuminate \ Mail \ Mailer :: send()必须是类型数组,给定对象,
所以我认为在这个日志中描述的问题是,你需要根据方法签名传递参数。但在你的问题的示例代码中缺少第一个参数。 (即您在发送方法中缺少Config::get('confide::email_account_confirmation'),
)。实际发送方法签名如下所示。
public function send($view, array $data, $callback)
尝试按照上面的示例代码修改代码。希望它会奏效。