【问题标题】:Address in mailbox given [address] does not comply with RFC 2822, 3.6.2给定 [address] 邮箱中的地址不符合 RFC 2822, 3.6.2
【发布时间】:2020-04-03 09:46:31
【问题描述】:

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

所以我的代码是:

验证控制器.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');

    }
}

用户.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));
    }
}

【问题讨论】:

    标签: php laravel


    【解决方案1】:

    经过几天和几个小时后,我意识到 Laravel 框架的版本存在差异。所以问题是我输入了端口:465,主机:smtp.gmail.com,谷歌给你的应用程序的用户名和密码,在 .env 文件中,mail.php, 在 config\config.php 中。 !我希望对未来的问题有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-01
      • 2012-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-03
      • 2014-02-27
      • 1970-01-01
      相关资源
      最近更新 更多