【问题标题】:Send the wrong url to the user's email by queuing to verify the email通过排队验证邮箱发送错误的url到用户邮箱
【发布时间】:2021-03-04 16:02:41
【问题描述】:

当我想使用 Laravel 的默认电子邮件验证器时效果很好但是当我将发送电子邮件的相同方法放入队列时,发送给用户的 url 是错误的

http://localhost/email/verify/65/36a5c019a9dc059333f38c329f3694d6ba646e36?expires=1614871373&signature=52f2f377d559a6bdd913b6fc210106b352ed1c60ff64cf1166d2b0ec562f086d

上面的 url 不正确,而不是 localhost:8000 只有 localhost 值

User Model 

 public function sendEmailVerificationNotification()
    {
        sendEmailVerify::dispatch($this);
    }


Job 

 public function __construct(User $user)
    {
   
        $this->user = $user;
    }
    
    public function handle()
    {
       $this->user->notify(new \App\Notifications\VerifyEmail());
    }

【问题讨论】:

  • .env 文件中 app_url 的值是多少?
  • @SachinKumar APP_URL=localhost
  • 然后检查我的答案
  • @SachinKumar 这只发生在排队时
  • 这将发生在所有独立运行的事情上,比如作业、队列电子邮件。一种快速的解决方案是设置 APP_URL=localhost:8000 但在这种情况下,您必须使用 php artisan serve 命令显式运行服务器,

标签: php laravel email queue


【解决方案1】:

存在这种问题是因为队列作业选择了 env 配置值,并且在您的情况下,我猜 APP_URL 设置为 http://localhost/。

所以将 APP_URL 更改为 .env 文件中本地服务器的路径,如

APP_URL=http://localhost/laravel

其中 laravel 是我运行项目的文件夹名称。

【讨论】:

    【解决方案2】:

    将 APP_URL 的值更改为

    APP_URL=http://localhost:8000
    

    然后运行 ​​php artisan config:clear 或 php artisan config:cache

    或者如果您使用的是 php artisan serve,只需重新启动它,它应该可以工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-04
      • 2017-10-10
      相关资源
      最近更新 更多