php - 未捕获的错误:将 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);
}
解决方案
您的应用程序正在引用自 Laravel 6 以来不存在的旧类。您应该考虑将其简化为仅使用Mail
. 这应该做你需要的一切。无论如何,大部分你已经拥有了。
推荐阅读
- reactjs - React + NextJS - 受保护的路线
- swift - 如何制作具有通用类数组属性的协议
- google-sheets - 在电子表格 API 中逐列搜索的正确方法是什么
- docker - 下载 Docker 映像时出现“意外的 EOF”
- type-conversion - 使用 FreePascal 将 QR 码转换为 WMF 流
- python - 在Python中以数组作为参数的函数内制作矩阵
- linux - CPack:排除特定的 RPM 依赖项
- java - Junit 测试场景不执行回滚
- reactjs - 是否可以配置 wdio 以使用不同的 tsconfig 文件?
- video - 如何从 FFmpeg 在 julia 的监视器中获取实时视频?