You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel Breeze密码重置触发Maximum execution time超时问题求助

Laravel Breeze密码重置超时(Maximum execution time exceeded)解决方案
  • 确认PHP配置实际生效
    修改php.ini中的max_execution_time后,必须重启Web服务器(Nginx/Apache)或PHP-FPM进程,否则配置不会生效。可以通过以下方式验证:

    • 在项目根目录创建phpinfo.php,写入<?php phpinfo(); ?>,访问该页面查看max_execution_time的实际值;
    • 执行命令php -i | grep max_execution_time,检查CLI模式下的配置(Web请求需关注Web环境的配置值)。
  • 改用队列异步发送邮件
    同步发送邮件会阻塞请求,SMTP连接延迟极易导致超时。将邮件发送改为异步处理:

    1. 在密码重置邮件类(如app/Mail/ResetPassword.php)中实现ShouldQueue接口:
      use Illuminate\Bus\Queueable;
      use Illuminate\Contracts\Queue\ShouldQueue;
      use Illuminate\Mail\Mailable;
      use Illuminate\Queue\SerializesModels;
      
      class ResetPassword extends Mailable implements ShouldQueue
      {
          use Queueable, SerializesModels;
          // 原有代码...
      }
      
    2. 配置队列驱动(以database为例):
      • 执行php artisan queue:table生成任务表迁移文件;
      • 执行php artisan migrate创建任务表;
      • 启动队列监听:php artisan queue:work。
  • 排查SMTP网络连接问题
    即便配置正确,服务器与Mailtrap的网络问题也可能导致超时:

    • 用telnet测试连接速度:telnet sandbox.smtp.mailtrap.io 2525,若连接缓慢或失败,需检查服务器防火墙规则,或尝试更换端口(如587);
    • 临时切换到log驱动验证流程:将.env中MAIL_MAILER改为log,触发密码重置后查看storage/logs/laravel.log,若日志正常生成,说明问题出在SMTP连接环节。
  • 调整邮件连接超时参数
    在发送邮件的代码中临时设置SMTP连接超时,避免长时间等待:

    // 在密码重置逻辑前添加
    config(['mail.connections.smtp.timeout' => 10]);
    config(['mail.connections.smtp.connection_timeout' => 10]);
    

内容的提问来源于stack exchange,提问作者Mohamed Hassan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 04:00:13