电子邮件验证Laravel 8



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

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

因为这是我得到的错误这是我在.env文件中的SMTP设置

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=abc@gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=admin@gmail.com
MAIL_FROM_NAME="${APP_NAME}"

这是我的用户模型代码

<?php
namespace AppModels;
use IlluminateContractsAuthMustVerifyEmail;
use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateFoundationAuthUser as Authenticatable;
use IlluminateNotificationsNotifiable;

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['sl']=数组('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.这对我很有用。

最新更新