给定[地址]的邮箱中的地址不符合RFC 2822,3.6.2

时间:2020-04-03 09:46:31

标签: php laravel

->用户创建帐户时,会向他发送一封验证电子邮件。这是我的目标。
->我正在与Laravel合作,我是新手。
->我正确设置了密码,用户名,端口,加密所需的STMP详细信息
- >我希望我很清楚。
->在email.php上,发件人是:“发件人” => [ 'from'=> ['address'=> null,'name'=> null],

所以我的代码是:

verifyController.php

namespace 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');

    }
}

User.php

<?php

namespace 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 个答案:

答案 0 :(得分:0)

几天又几小时后,我意识到Laravel框架的版本有所不同。所以问题是我有输入端口:465,主机:smtp.gmail.com,Google提供给您的应用程序的用户名和密码,以及.env文件,mail.php, 在config \ config.php中。 !我希望能对以后的问题有所帮助。