在服务器上执行代码时显示错误...
页面无法提交表格
控制器代码
class SaveFormController extends Controller {
public function create(){
return view('/join-our-team');
}
public function store(SaveFormRequest $request){
$data = Input::all();
Mail::send('emails.reply', $data, function($message){
$message->from($data['email'] , $data['name']);
$message->to('abc@asd.com' , 'team');
});
return redirect('/');
}
}
我的HTML代码是
<ul style="background: rgb(255, 210, 210);">
@foreach($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
{!! Form::open(array('route' => 'applicant_store', 'class' => 'form')) !!}
<div class="form-group">
{!! Form::label('Your Name') !!}
{!! Form::text('name', null,
array('class'=>'form-control',
'placeholder'=>'Your name')) !!}
</div>
<div class="form-group">
{!! Form::label('Your E-mail Address') !!}
{!! Form::text('email', null,
array('class'=>'form-control',
'placeholder'=>'Your e-mail address')) !!}
</div>
<div class="form-group">
{!! Form::label('Your Education') !!}
{!! Form::select('education', ['Post Graduate', 'Graduate', '12th'], null, ['class'=>'form-control'] ) !!}
</div>
<div class="form-group">
{!! Form::label('Your Contact No.') !!}
{!! Form::text('phone', null,
array('class'=>'form-control',
'placeholder'=>'Your 10 digit Mobile No.')) !!}
</div>
{!! Form::label('Experience') !!}
<div class="row">
<div class="col-md-6">
<div class="form-group">
{!! Form::label('Years') !!}
{!! Form::select('year',[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, '10+'],null, ['class'=>'form-control']) !!}
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{!! Form::label('Months') !!}
{!! Form::select('month',[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],null, ['class'=>'form-control']) !!}
</div>
</div>
</div>
<div class="form-group">
{!! Form::label('Resume (doc,docx,pdf format)') !!}
{!! Form::file('applicant_resume',['class'=>'form-control']) !!}
</div>
<div class="form-group">
{!! Form::submit('Submit Details',
array('class'=>'btn btn-success')) !!}
</div>
{!! Form::close() !!}
我的app / mail.php配置
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.abc.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => 'my_mail', 'name' => 'team'],
'encryption' => 'tls',
'username' => env('my_email'),
'password' => env('my_pwd'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
];
尝试diffetrent后无法找到错误......
请帮我解决问题..
答案 0 :(得分:0)
您的问题是您传递给邮件功能的数据。第二个参数用于发送到不在函数内的视图的数据。将其更改为此
public function store(SaveFormRequest $request){
$data = Input::all();
Mail::send('emails.reply', $data, function($message) use($data) {
$message->from($data['email'] , $data['name']);
$message->to('abc@asd.com' , 'team');
});
return redirect('/');
答案 1 :(得分:0)
如果你的html代码和控制器没问题,你只需要......像这样改变文件......
配置/ mail.php
'driver' => env('MAIL_DRIVER', 'mail'),
'host' => env('MAIL_HOST', 'www.yourdomain.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => 'info@domain.com', 'name' => name'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
并将.env文件更改为
MAIL_DRIVER=mail
MAIL_HOST=www.yourdomain.com
MAIL_PORT=587
MAIL_USERNAME=email address
MAIL_PASSWORD=your email plassword
MAIL_ENCRYPTION=null
希望它能起作用