Email sending problem

We are facing a problem in our production server where Yii::$app->mailer->send() is giving internal server error with following error message in the log.

Same code is working well in the development system. Other applications on the same server are working fine. So there is no general issue with the mail as such. We have also tried copying entire vendor folder from a perfectly working development system, which didn’t seem to help. Any input on where I can look into?

2019/10/04 13:57:16 [error] 18772#18772: *45056 FastCGI sent in stderr: “PHP message: An Error occurred while handling another error:
Error: Call to undefined method Swift_IoException::getName() in /usr/share/nginx/html/controllers/SiteController.php:3702
Stack trace:
#0 [internal function]: app\controllers\SiteController->actionError()
#1 /usr/share/nginx/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#2 /usr/share/nginx/html/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#3 /usr/share/nginx/html/vendor/yiisoft/yii2/base/Module.php(528): yii\base\Controller->runAction(‘error’, Array)
#4 /usr/share/nginx/html/vendor/yiisoft/yii2/web/ErrorHandler.php(108): yii\base\Module->runAction(‘site/error’)
#5 /usr/share/nginx/html/vendor/yiisoft/yii2/base/ErrorHandler.php(111): yii\web\ErrorHandler->renderException(Object(Swift_IoException))
#6 [internal function]: yii\base\ErrorHan” while reading upstream, client: 45.119.130.4, server: app.myserver.com, request: “GET /279124de44ba40368b228da4f96814cf/mailtest HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php/php7.0-fpm.sock:”, host: “app.myserver.com