Now i send my form data to email account, [email protected], using function:
public function ContactExemple()
{
$email = Input::get('email');
$subiect = Input::get('phone');
Mail::send('email', [
'name'=>Input::get('name'),
'email'=>$email,
'phone'=>$phone,
'msg'=>Input::get('msg')
], function($m) use($email, $subiect) {
$m->from($email);
$m->to(' [email protected]')->subject($subiect);
});
return Redirect::to(URL::previous() . "#contact_form")->with('message', 'THANKS FOR YOUR MSG!');
}
而且我的觀點:AJAX Laravel - 將表單數據發送到電子郵件
<form action="{{url('/'.$lang)}}" method="POST" >
<input type="hidden" name="_token" value="{{ csrf_token() }}"> {!! csrf_field() !!}
<input type="text" name="name">
<input type="email" name="email" type="email">
<input type="text" name="phone" type="text">
<textarea name="msg"></textarea>
<input type="submit" value="submit" name="submit"> </input>
@if(Session::has('message')) <p class="alert alert-info"> {{Session::get('message')}} </p> @endif
</form>
路線:
Route::get('/', '[email protected]');
Route::post('/', '[email protected]');
我需要做到這一點使用AJAX,但找不到任何可以幫助我做到這一點,有很多簡單的ajax post請求的例子,但我需要整合它與發送到我的電子郵件帳戶這種形式的數據。