大家好我需要帮助才能在电子邮件上发送代码[laravel]
我收到了一封电子邮件,但没有像这样的链接和用户名
Hello username
请使用以下链接激活您的帐户
链路
这是我的代码
activate.blade.php
您好{{'username'}}
请使用以下链接激活您的帐户
---
{{'link'}}
的AccountController
<?php
类AccountController扩展BaseController {
public function getCreate() {
return View::make('account.create');
}
public function postCreate() {
$validator = Validator::make(Input::all(),
array(
'email' => 'required|max:50|email|unique:users',
'username' => 'required|max:20|min:3|unique:users',
'password' => 'required|min:6',
'password_again' => 'required|same:password'
)
);
if($validator->fails()) {
return Redirect::route('account-create')
->withErrors($validator)
->withInput();
} else {
$email = Input::get('email');
$username = Input::get('username');
$password = Input::get('password');
//Activation code
$code = str_random(60);
$user = User::create(array(
'email' => $email,
'username' => $username,
'password' => Hash::make($password),
'code' => $code,
'active' => 0
));
if($user) {
Mail::send('emails.auth.activate', array('link' => URL::route('account-activate', $code), 'username' => $username), function($message) use ($user) {
$message->to($user->email, $user->username)->subject('Activate your account');
});
return Redirect::route('home')
->with('global', 'Your account has been created! We have sent you an email to activate your account.');
}
}
}
public function getActivate($code) {
}
}
家庭控制器
<?php
类HomeController扩展BaseController { public function home(){
Mail::send('emails.auth.activate', array('name' => 'NoReply'), function($message){
$message->to('noreply@bla.com', 'Noreply')->subject('Noreplymail');
});
return View::make('home');
}
}
提前致谢。
答案 0 :(得分:0)
在 activate.blade.php 中尝试:
Hello {{ $username }} <br> Please activate your account using the following link <br> --- <br> {{ $link }}