我正在尝试发送带有表单详细信息的电子邮件。我成功发送了一封包含电子邮件信息的邮件,但是当我尝试添加更多数据时,我会收到错误,例如未定义的var等。
发送邮件后,我想重定向到一个新视图,说明'感兴趣的是联系我们"在回到索引之前。有帮助吗? :(
控制器
<?php
namespace App\Http\Controllers;
use App\Http\Requests\ContactFormRequest;
class AboutController extends Controller {
public function create()
{
return view('contact');
}
public function store(ContactFormRequest $request)
{
echo "<pre>"; print_r($request->all());
die();
function($message)
{
$message->from('wj@wjgilmore.com');
$message->to('x@gmail.com', 'Admin')->subject('x');
});
return \Redirect::route('contact')->with('message', 'Thanks for contacting us!');
}}
表格
{!! Form::open(array('route' => 'contact', 'class' => 'form')) !!}
<h3>Prestation</h3>
<label class="grid_16">
<span class="label grid_5">x</span>
{!! Form::select('event_types', $event_types) !!}
</label>
<label class="grid_16">
<span class="label grid_5">x</span>
<input type="date" name="date"/>
</label>
<label class="grid_16">
<span class="label grid_5">x</span>
{!! Form::select('personnes', $personnes) !!}
</label>
<label class"grid_16">
<span class="label grid_5">x</span>
{!! Form::text('lieu') !!}
</label>
<label class="grid_16">
<span class="label grid_5">x</span>
{!! Form::select('rayon_km', $rayon_km) !!}
</label>
<label class="grid_16">
<span class="label grid_5">Tx</span>
<ul class="grid_8">
@foreach($accessoires as $value => $front)
<li>
<label>
{!! Form::checkbox('accessoires[]', $value) !!}
{{ $front }}
</label>
</li>
@endforeach
</ul>
</label>
<label class="grid_16">
<span class="label grid_5">x</span>
<textarea name="informations" rows="5" cols="70"></textarea>
</label>
<h3>Coordonnées</h3>
<label class="grid_16">
<span class="label grid_5"> x</span>
{!! Form::select('civilite', $civilite) !!}
</label>
<label class="grid_24">
<span class="label grid_5"> x</span>
{!! Form::text('prenom') !!}
</label>
<label class="grid_24">
<span class="label grid_5"> x</span>
{!! Form::text('nom') !!}
</label>
<label class="grid_24">
<span class="label grid_5"> x</span>
{!! Form::text('telephone') !!}
</label>
<label class="grid_24">
<span class="label grid_5"> x</span>
{!! Form::email('email') !!}
</label>
<label class="grid_24">
<span class="label grid_5"> x</span>
{!! Form::text('telephone2') !!}
</label>
<label class="grid_24">
<span class="label grid_5"> x</span>
{!! Form::text('horaires') !!}
</label>
<div class="grid_24">
{!! Form::submit('Envoyer', '', array('class'=>'btn btn-primary')) !!}
</div>
{!! Form::close() !!}
ContactFormRequest
<?php
namespace App\Http\Requests;
use App\Http\Requests\Request;
class ContactFormRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'prenom' => 'required',
'nom' => 'required',
'email' => 'required|email',
//
];
}
}
电子邮件视图
<p>
Type d'évènement : {{ $event_types }} </br>
Date de l'évènement : {{ $date }}
Nombre de personnes conviées : {{ $personnes }} </br>
Lieu de l'évènement : {{ $lieu }}
Rayon Km : {{ $rayon_km }} </br>
Accessoires nécessaires : {{$accessoires}} </br>
Civilité : {{ $civilite }}
Nom : {{ $nom }}
Prénom : {{ $prenom }}
Adresse mail : {{ $email }}
Téléphone : {{ $telephone }}
Téléphone facultatif {{ $telephone2 }}
Horaires pouvant être joignable : {{ $horaires }}
答案 0 :(得分:0)
在email.hello
视图中,您正在调用$informations
变量
Informations : {{ $informations }}
但您没有从$informations
方法
email
变量
缺少这个
array(
'informations' => $request->get('informations'),
),
<强>更新强>
而不是使用
$request->get()
使用此
$request->input()
我的电子邮件脚本
$to_username = $to_array['to_username'];
$from_goodname = $to_array['from_goodname'];
$link = $to_array['link'];
$link = '<a href="'.$link.'" target="_blank"> '.$link.'</a>';
$user_data = ['to_username'=>$to_username, 'from_goodname'=>$from_goodname, 'link'=>$link];
return Mail::send('emails.invite', $user_data, function($message) use ($to_array) {
$to_username = $to_array['to_username'];
$to_goodname = $to_array['to_username'];
$to_subject = 'New Invitation to SMP System!';
$message->to($to_username, $to_username)->subject($to_subject);
});
我的观看内容
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
</head>
<body>
<h2>Invitation</h2>
<div class="row-fluid">
<p>Hello {{$to_username}}</p>
<p> You have been invited by {!!$from_goodname!!} to Secure Messaging Portal,
Please follow the link to complete the information steps.
<br /><br />
</p>
<p> {!!$link!!} </p>
<p>Thanks</p>
</div>
</body>
</html>