我在laravel 5.8中具有自定义注册控制器,它返回:
没有发件人地址就无法发送消息
Controller
public function newRegisterSend(Request $request) {
$this->validate($request, array(
'username' => ['required', 'string', 'max:255', 'unique:users'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
));
$user = User::create([
'username' => $request->input('username'),
'email' => $request->input('email'),
'password' => Hash::make($request->input('password')),
'first_login' => Carbon::now(),
]);
$profile = new Profile;
$profile->user_id = $user->id;
$profile->save();
$user->assignRole('non-employee');
$user->changee()->insert([
'changeable_id' => $user->id,
'changeable_type' => 'App\User',
'creator_id' => $user->id,
'updator_id' => null,
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
]);
$user->sendEmailVerificationNotification(); // sending verification email
return $user;
}
route
Auth::routes([ 'register' => false, 'verify' => true ]);
user model
class User extends Authenticatable implements MustVerifyEmail {
//...
}
.env
MAIL_FROM_ADDRESS=example@example.com
MAIL_FROM_NAME=MyApp
有什么主意吗?