首页 > 解决方案 > 未捕获的错误:将 laravel 5.8 升级到 8 后调用未定义的函数 Illuminate\Mail\TransportManager()

问题描述

当我将 Laravel 5.8 升级到 8 时在 handler.php 中给出错误,而我是 composer update 调用未定义的函数 Illuminate\Mail\TransportManager() 如何解决这些请帮助..

public function report(Throwable $exception) {

    Config::set('mail.driver', 'smtp');
    Config::set('mail.port', 587);
    Config::set('mail.host', 'mail.ccc.com');
    Config::set('mail.username','test@gmail.com');
    Config::set('mail.password','UKK(a^}#~Fr[');
    Config::set('mail.from.address','error-reporting@gmail.com');
    Config::set('mail.from.name','test');
    Config::set('mail.encryption','tls');
    $app = \App::getInstance();

    $app->singleton('swift.transport', function ($app) {
        return \Illuminate\Mail\TransportManager($app);
    });

    $mailer = new \Swift_Mailer($app['swift.transport']->driver());
    \Mail::setSwiftMailer($mailer);

   if (!$exception instanceof TokenMismatchException) {
       if (!$this->isHttpException($exception)) {
           if ($exception->getMessage() != 'Unauthenticated.') {
               $handler = new SymfonyExceptionHandler();
               $exceptionHtml = $handler->getHtml($exception);
               $subject = 'Error Reporting : ' . $exception->getMessage();
                $cc = 'testmail@gmail.com';
                $to = 'testmail@gmail.com';

                $data = array('msg'=>$exceptionHtml);
               
                 $ss = \Mail::send('email.error-reporting-message', $data, function ($message) use ($to,$cc,$subject)
                             {
                                 $message->to($to, 'Test')
                                         ->cc($cc, 'Test')
                                         ->subject($subject);
                             });
                
           }
       }
   }
    parent::report($exception);
}

标签: phplaravellaravel-upgrade

解决方案


您的应用程序正在引用自 Laravel 6 以来不存在的旧类。您应该考虑将其简化为仅使用Mail. 这应该做你需要的一切。无论如何,大部分你已经拥有了。


推荐阅读