拉拉维尔的新手很善良哈哈
我对mail.php的配置是正确的,并且正在成功接收电子邮件以便将文本输入到gmail,但不确定如何完成文件的任务.我将不胜感激一些帮助或参考链接.
提前致谢!!
routes.php中的代码
Route::get('/', function()
{
return View::make('form');
});
Route::post('/form', function()
{
$data = ['firstname' => Input::get('firstname'), 'username' => Input::get('username'), 'email' => Input::get('email'), 'resume' => Input::get('resume') ];
$rules = array(
'username' => 'Required|Min:7',
'email' => 'Required|Email',
'firstname' => 'Required',
'resume' => 'Required'
);
$validation = Validator::make(Input::all(), $rules);
if ($validation->fails())
{
// Validation has failed.
return Redirect::to('/')->withInput()->withErrors($validation);
}
else {
Mail::send('emails.welcome', $data, function($message)
{
$message->to('mail@domain.net');
$message->subject('Welcome to Laravel');
$message->from('sender@domain.net');
});
return Redirect::to('/')->withInput()->with('success', 'Thank you for your submission.');
}
//
});
form.blade.php中的代码
Form@if(Session::has('success'))
{{ Session::get('success') }}
@endif
{{ Form::open(array('url' => '/form')) }}
{{ Form::label('email', 'E-Mail Address');}}
{{ Form::email('email', 'example@mail.com');}}
{{ $errors->first('email') }}
{{ Form::label('username', 'Username');}}
{{Form::text('username');}}
{{ $errors->first('username') }}
{{ Form::label('firstname', 'First Name');}}
{{Form::text('firstname');}}
{{ $errors->first('firstname') }}
{{ Form::file('resume'); }}
{{Form::submit('Send Details');}}
{{ Form::close() }}