I am new to Laravel. I am trying to send email with attachments
here what I try.
in my app/config/mail
'driver' => 'mail',
this is my Route
Route::get('join-us', 'handleFormController@joinus');
Route::post('joinRequest', 'handleFormController@getJoinRequest');
and this is the form
{{ Form::open(array('url'=>'joinRequest', 'files'=>'true')) }}
@foreach($errors->all('
:message
') as $message) {{ $message }}
@endforeach
<div class="form-group pull-right ">
{{ Form::label('name', ' ') }}
<div class="col-xs-12">
{{ Form::text('name', '', array('class'=>'form-control1 row input-sm', 'placeholder'=>'الاسم')) }}
</div>
</div>
<div class="form-group pull-right ">
{{ Form::label('email', ' ') }}
<div class="col-xs-12">
{{ Form::text('email', '', array('class'=>'form-control1 row input-sm', 'placeholder'=>'البريد الإلكتروني')) }}
</div>
</div>
<div class="form-group pull-right ">
{{ Form::label('job', ' ') }}
<div class="col-xs-12">
{{ Form::text('job', '', array('class'=>'form-control1 row input-sm', 'placeholder'=>'المهنة او الوظيفة الحاليه')) }}
</div>
</div>
<div class="form-group pull-right ">
{{ Form::label('comment', ' ') }}
<div class="col-xs-12">
{{ Form::textarea('comment', '', array('class'=>'form-control1 row input-sm', 'placeholder'=>'اترك تعليق')) }}
</div>
</div>
{{--<div class="form-group pull-right ">
{{ Form::label('resume', ' ') }}
<div class="col-xs-12">
{{ HTML::script('siteroot/fileinput.js') }}
{{ Form::file('resume', array('class'=>'file')) }}
</div>
</div>--}}
<div class="col-xs-12 pull-right">
{{ Form::submit('أرسال', array('class'=>'btn btn-primary pull-right')) }}
</div>
{{Form::close()}}
and here is my controller
public function getJoinRequest()
{
$data = Input::all();
$rules = array(
'name' => 'required|regex:/^[\pL\s\-]+$/u',
'email' => 'required|email',
'job' => 'required|alpha',
'comment' => 'required|min:25'
);
$validator = Validator::make($data, $rules);
if ($validator->passes()) {
Mail::send('emails.joinRetunMessage.hello', $data, function ($message) use ($data) {
$message->from($data['email'], $data['name']);
$message->to('johnef_sh@hotmail.com', 'El Arabia')->subject('Join us request');
/*$message->attach($data['resume']->getRealPath(), array(
'as' => 'resume.' . $data['resume']->getClientOriginalExtension(),
'mime' => $data['resume']->getMimeType())
);*/
});
return Redirect::to('/join-us')
->with('message', 'Your message has been sent. Thank You!');
} else {
return Redirect::to('/join-us')->withErrors($validator);
}
}
when I submit the form it returns to page without any errors, but the mail was not sent.