[英]Laravel 5 Sending email to owner after a user register
I'm using the default login and registration system of Laravel. 我正在使用Laravel的默认登录和注册系统。 I just want to do whenever a new user was successfully registered an email will be sent to one of the email address that I will input, like sending an email to me to notify me that a new user register.
我只想在每位新用户成功注册后就将电子邮件发送到我要输入的电子邮件地址之一,例如向我发送电子邮件以通知我有新用户注册。
How will I do this? 我该怎么做?
You can simply overwrite register
method in AuthController
. 您可以简单地在
AuthController
覆盖register
方法。
Put something like this and it will send super simple email to registered user: 放这样的东西,它将向注册用户发送超级简单的电子邮件:
public function register(Request $request)
{
// original script, do not touch it
$validator = $this->validator($request->all());
if ($validator->fails()) {
$this->throwValidationException(
$request, $validator
);
}
\Auth::guard($this->getGuard())->login($this->create($request->all()));
// Your custom script
\Mail::raw('Welcome ' . $request->input('name') . '!', function ($m) use ($request) {
$m->to($request->input('email'))->subject('Registration successful!');
});
return redirect($this->redirectPath());
}
To learn more about mailing, You should read official docs: https://laravel.com/docs/5.2/mail 要了解有关邮寄的更多信息,您应该阅读官方文档: https : //laravel.com/docs/5.2/mail
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.