You should definitely use mailer
service, as it's an alias to the correct swiftmailer service, regardless how it named. For example im v2.3.3 it's swiftmailer.mailer.default
But you have to use
$container->findDefinition('mailer');
which unlike
getDefinition()
also resolves aliases so if the$serviceId
argument is an alias you will get the underlying definition.