电子邮件验证Laravel 8

问题描述

我正在使用 laravel 8,并试图在注册时验证我的电子邮件 并出现错误

没有发件人地址就无法发送消息

this is error i'm getting 这是我的.env文件中的 SMTP设置

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
[email protected]
MAIL_FROM_NAME="${APP_NAME}"

这是我的用户模型代码

    <?PHP

namespace App\Models;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;


class User extends Authenticatable implements MustVerifyEmail
{
    use HasFactory,Notifiable,HasRoles;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name','email','password',];

    /**
     * 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',];
   
   
}

这是我来自web.PHP路线

Auth::routes(['verify' => true]);

解决方法

改变你的端口或者你可以做php artisan config:cache

,

转到文件夹 vendor\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php 然后更改 $options = []; to $options['ssl'] = array('verify_peer' => false,'verify_peer_name' => false,'allow_self_signed' => true);

我在这里找到了解决方案 https://laracasts.com/discuss/channels/laravel/stream-socket-enable-crypto-ssl-operation-failed-with-code-laravel-7。它对我有用。