Adding attachment using Swiftmailer
Swiftmailer currently expects a plain \stdClass object in files as this part hasn't been fully ported from D7. See https://www.drupal.org/node/2713651.

So you need to do something like

$file = (object) [
'filename' =&gt; $file-&gt;getFilename(),
'uri' =&gt; $file-&gt;getFileUri(),
'filemime' =&gt; $file-&gt;getMimeType(),
];
$message['params']['files'][] = $file;