-> 當(dāng)用戶創(chuàng)建帳戶時(shí),會(huì)向他發(fā)送一封驗(yàn)證郵件。這是我的目標(biāo)。->我正在使用 Laravel,我是新手。->我正確設(shè)置了所需的 STMP 詳細(xì)信息,如密碼、用戶名、端口、加密->我希望我是清楚的。->在 email.php 中,發(fā)件人是:“發(fā)件人”=> [“發(fā)件人”=> [“地址”=> null,“名稱”=> null],所以我的代碼是:驗(yàn)證控制器.phpnamespace App\Http\Controllers;use App\User;use Illuminate\Http\Request;class VerifyController extends Controller{ /** * verify the user with a given token * * */ public function verify($token) User::where('token', $token)->firstOrFail(); $this->update(['token' => null]); //verify the user return redirect('/profile'); $this->route('home') ->with('success', 'Account verifed'); }}用戶.php<?phpnamespace App;use App\User;use Illuminate\Contracts\Auth\MustVerifyEmail;use App\Notifications\VerifyEmail;use Illuminate\Notifications\Notifiable;use Illuminate\Foundation\Auth\User as Authenticatable;class User extends Authenticatable implements MustVerifyEmail{ use Notifiable; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'email', 'password', 'token' ]; /** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', ]; public function orders(){ return $this->hasMany('App\Order'); } /** * Returns true if user is verified * @return bool * */ public function verified() { return $this->token === null; } /** * Send the user a verification user * @return void * * * * */ public function sendVerificationEmail() { $this->notify(new VerifyEmail($this)); }}
1 回答

波斯汪
TA貢獻(xiàn)1811條經(jīng)驗(yàn) 獲得超4個(gè)贊
幾天幾小時(shí)后,我意識到 Laravel Frameworks 的版本存在差異。所以問題是我有輸入端口:465,主機(jī):smtp.gmail.com,谷歌給你的應(yīng)用程序的用戶名和密碼,以及 .env 文件,mail.php,也在config\config.php 中。!我希望對以后有關(guān)它的問題有所幫助。
- 1 回答
- 0 關(guān)注
- 233 瀏覽
添加回答
舉報(bào)
0/150
提交
取消