-> 當用戶創建帳戶時,會向他發送一封驗證郵件。這是我的目標。->我正在使用 Laravel,我是新手。->我正確設置了所需的 STMP 詳細信息,如密碼、用戶名、端口、加密->我希望我是清楚的。->在 email.php 中,發件人是:“發件人”=> [“發件人”=> [“地址”=> null,“名稱”=> null],所以我的代碼是:驗證控制器.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貢獻1811條經驗 獲得超4個贊
幾天幾小時后,我意識到 Laravel Frameworks 的版本存在差異。所以問題是我有輸入端口:465,主機:smtp.gmail.com,谷歌給你的應用程序的用戶名和密碼,以及 .env 文件,mail.php,也在config\config.php 中。!我希望對以后有關它的問題有所幫助。
- 1 回答
- 0 關注
- 219 瀏覽
添加回答
舉報
0/150
提交
取消