提前感谢您的回答。我不知道我做了什么不好的联系表格,变量在views / emails / contact.blade.php
{{ Form::open(array('action' => 'PagesController@contact','method' => 'POST', 'role' =>'form', 'class' =>'form-horizontal' )) }}
<div class="form-group">
{{ Form::label('name', 'Nombre:', ['class' => '']) }}
{{ Form::text('name', '', ['class' => 'form-control', 'maxlength' => 20]) }}
</div>
<div class="form-group">
{{ Form::label('email', 'Email:', ['class' => '']) }}
{{ Form::email('email', '', ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('subject', 'Asunto:', ['class' => '']) }}
{{ Form::text('subject', '', ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('country', 'Pais:', ['class' => '']) }}
{{ Form::text('country', '', ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('textarea', 'Message:', ['class' => '']) }}
{{ Form::textarea('msg', '', ['class' => 'form-control', 'placeholder' =>'Your Message', 'required'=>'true']) }}
</div>
<div class="form-group">
{{ Form::submit('Send', array('class' => 'btn btn-primary btn-md')) }}
</div>
{{ Form::close() }}
Name: {{ $name }}
Email: {{ $email }}
Country: {{ $country }}
Subject: {{ $subject }}
Message: {{ $msg }
{{ $detail }}
Route::get('/contact', array('as' =>'contact', 'uses'=> 'PagesController@contact'));
Route::post('contact', 'PagesController@contact');
public function contact(){
return View::make('contact');
}
public function postContact(){
$user = array(
'email'=>'africamia@gmail.com',
'name'=>'Laravelovich'
);
// the data that will be passed into the mail view blade template
$data = array(
'detail'=>'Your awesome detail here',
'name' => $user['name']
);
// use Mail::send function to send email passing the data and using the $user variable in the closure
Mail::send('emails.contact', $data, function($message) use ($user){
$message->from('africamia@gmail.com', 'Admin');
$message->to($user['email'], $user['name'])->subject('Welcome to My Laravel app!');
});
return View::make('gracias');
}
return array(
'driver' = 'smtp',
'host' = 'smtp.gmail.com',
'port' = 587,
'from' = array('address' = 'africamia@gmail.com', 'name' = 'Admin'),
'encryption' = 'tls',
'username' = 'africamia@gmail.com',
'password' = '123456',
'sendmail' = '/usr/sbin/sendmail -bs',
'pretend' = false,
);
答案 0 :(得分:0)
您需要将email
,country
,subject
和msg
添加到emails.contact