0
我對此有點新鮮。使用Laravel 4.2和Mailgun發送郵件
我讀過Laravel 4和一些Mailgun的文檔,我已經測試了一些郵件和工作,但就在這樣的路線:
Route::get('send_test_email', function(){
Mail::send('emails.registro', array('key' => 'value'), function($message)
{
$message->subject('Bienvenido a la gran experiencia');
$message->from(env('CONTACT_MAIL'), env('CONTACT_NAME'));
$message->to('[email protected]');
});
});
我去的myapp/send_test_email在瀏覽器中,並得到一封電郵。
但現在我想給在註冊的電子郵件,我創建的路線:
Route::get('mail', ['uses' => '[email protected]', 'as' => 'send']);
控制器:
<?php
class MailController extends \BaseController {
public function index()
{
return View::make('signup');
}
public function send() {
Mail::send('emails.registro', $data, function($message) use
{
$message->subject('Bienvenido a la gran experiencia');
$message->from(env('CONTACT_MAIL'), env('CONTACT_NAME'));
$message->to($user->email, $user->firstname);
});
}
,並增加了表格申請表單是這樣的:
{{ Form::open(['route' => 'send', 'method' => 'get']) }}
<div class="form-group">
{{ Form::label('username', 'Usuario', ['class' => 'sr-only']) }}
{{ Form::text('username', null, ['placeholder' => 'Usuario', 'required', 'minlength' => 6, 'class' => 'form-control', ]) }}
@foreach($errors->get('username', '<span class=error>:message</span>') as $message)
{{$message}}
@endforeach
</div>
<div class="form-group">
{{ Form::label('password', 'Contraseña', ['class' => 'sr-only']) }}
{{ Form::password('password', ['placeholder' => 'Contraseña', 'required', 'minlength' => 8, 'class' => 'form-control']) }}
@foreach($errors->get('password', '<span class=error>:message</span>') as $message)
{{$message}}
@endforeach
</div>
<div class="form-group">
{{ Form::label('password_confirm', 'Confirmar Contraseña', ['class' => 'sr-only']) }}
{{ Form::password('password_confirmation', ['placeholder' => 'Confirmar Contraseña', 'required', 'minlength' => 8, 'class' => 'form-control']) }}
@foreach($errors->get('password_confirmation', '<span class=error>:message</span>') as $message)
{{$message}}
@endforeach
</div>
<div class="form-group">
{{ Form::label('email', 'Email', ['class' => 'sr-only']) }}
{{ Form::email('email', null, ['placeholder' => 'Email', 'required', 'class' => 'form-control']) }}
@foreach($errors->get('email', '<span class=error>:message</span>') as $message)
{{$message}}
@endforeach
</div>
<div class="form-group">
{{ Form::label('firstname', 'Nombres', ['class' => 'sr-only']) }}
{{ Form::text('firstname', null, ['placeholder' => 'Nombres', 'required', 'class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('lastname', 'Apellidos', ['class' => 'sr-only']) }}
{{ Form::text('lastname', null, ['placeholder' => 'Apellidos', 'required', 'class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::submit('Registrar', ['class' => 'btn btn-lg btn-block btn-kinbu'])}}
</div>
{{ Form::close() }}
而我在控制器中得到Parse error: syntax error, unexpected 'Mail' (T_STRING)
,爲什麼?