Laravel 5.1 如何在注册后发送电子邮件验证邮件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32028973/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 5.1 How to send email verification email after registration?
提问by Ali Erfani
I need users to verify their email address after registration. I have confirmation_code and confirmed fields in users table. How can I send an email after a user registration?
我需要用户在注册后验证他们的电子邮件地址。我在用户表中有confirmation_code 和confirmed 字段。用户注册后如何发送电子邮件?
回答by cre8
You need a normal blade template being the body
你需要一个普通的刀片模板作为主体
Mail::send('emails.reminder', ['user' => $user], function ($m) use ($user) {
$m->to($user->email, $user->name)->subject('Your Reminder!');
});
In just place a the confirmation_code
in the email and define a route, e.g.
mypage.com/emailverification/1389734jhikdfsjkb1234908adkb
只需confirmation_code
在电子邮件中放置一个并定义一个路由,例如 mypage.com/emailverification/1389734jhikdfsjkb1234908adkb
When the user vists the link you check the database for this entry and set the status of the registration to completed.
当用户访问该链接时,您检查该条目的数据库并将注册状态设置为已完成。
For more information check http://laravel.com/docs/5.1/mail#sending-mail
有关更多信息,请查看http://laravel.com/docs/5.1/mail#sending-mail
For a detailed tutorial check: http://bensmith.io/email-verification-with-laravel
有关详细的教程检查:http: //bensmith.io/email-verification-with-laravel