How to override email settings in cake4

In cake4 i sometimes want to send from a different email so i need to override the settings in app_local.
The docs on this are not clear in what to do as no complete example is in Mailer - 4.x

this gives an error on send . With such vague instructions on doing this , i dont know what else to do

 use Cake\Mailer\Mailer;
 use Cake\Mailer\MailerAwareTrait;
 use Cake\Mailer\TransportFactory;

 public function sendemailoverride($to ,$from,$subject,$message) {

                  
           TransportFactory::drop('gmail3'); // If you wish to modify an existing configuration, you should drop it, change configuration and then re-add it.
           TransportFactory::setConfig('gmail3', [
                'host' => 'ssl://smtp.gmail.com',
                'port' => 465,
                'username' => 'xxx@gmail.com',
                'password' => 'xxx',
                'className' => 'Smtp',
            ]);
       
           $mailer = new Mailer();
           $mailer->setTransport('gmail3');
            $mailer->setFrom(['xxx@gmail.com' => 'My Email'])
             ->setTo($to)
             ->setSubject($subject)
             ->deliver($message);
            //->send('user', [$user]);            
        
        }//public

found the answer as you ust override in the constructor, not a function