SwiftMessageToEmailRector

Convert \Swift_Message into an \Symfony\Component\Mime\Email

-$message = (new \Swift_Message('Hello Email'))
-        ->setFrom('send@example.com')
-        ->setTo(['recipient@example.com' => 'Recipient'])
-        ->setBody(
-            $this->renderView(
-                'emails/registration.html.twig',
-                ['name' => $name]
-            ),
-            'text/html'
-        )
+$message = (new Email())
+    ->from(new Address('send@example.com'))
+    ->to(new Address('recipient@example.com', 'Recipient'))
+    ->subject('Hello Email')
+    ->html($this->renderView(
+        'emails/registration.html.twig',
+        ['name' => $name]
+    ))
+;

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\Symfony\SwiftMailer\Rector\ClassMethod\SwiftMessageToEmailRector;

return RectorConfig::configure()
    ->withRules([
        SwiftMessageToEmailRector::class,
    ]);