在默认注册表格中,我正在输入姓名电子邮件密码,状态为默认0.我的电子邮件正在发送,但是从我发送给我..我想从注册时输入的电子邮件中发送电子邮件地址我给了电子邮件ID。我试过这样......
<?php
namespace App\Http\Controllers\Auth;
use Mail;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Auth;
use DB;
use Illuminate\Support\Facades\Input;
class RegisterController extends Controller
{
use RegistersUsers;
protected $redirectTo = '/regmessage';
public function __construct()
{
$this->middleware('guest');
}
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
/*'usertype' => 'required',*/
]);
}
protected function create(array $data)
{
$user=User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
/*'usertype' =>$data['usertype'],*/
'status' => 0,
]);
$use = array('name' => 'Admin');
Mail::send('emailMessage', $use, function ($m) use ($data){
$m->from($data['email'])
->to('mrbbangladesh2017@gmail.com')
->subject('Confirm email');
});
return $user;
}
}
答案 0 :(得分:0)
尝试以下create()
功能代码:
protected function create(array $data)
{
$user=User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
/*'usertype' =>$data['usertype'],*/
'status' => 0,
]);
$use = array('name' => 'Admin', 'userEmail' => $data['email']);
Mail::send('emailMessage', $use, function ($m) use ($use){
$m->from($use['userEmail'])
->to('mrbbangladesh2017@gmail.com')
->subject('Confirm email');
});
return $user;
}
这应该有效!