Q: Mailer Cakephp 4 unable to connect to tcp I'm trying to send emails from a controller (in place of *** is my actual gmail), I'm working on local:
mailer = new Mailer('default');
        $mailer->setFrom(['***@gmail.com' => 'Savepets'])
            ->setTo('****@gmail.com')
            ->setSubject('About')
            ->deliver('blablabla');

And I have this in the app_local.php:
'EmailTransport' => [
    // Sample Mail configuration
    'default' => [
        'className' => 'Smtp',
        'host' => 'localhost',
        'port' => 25,
        'username' => null,
        'password' => null,
        'client' => null,
        'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
    ],
    // Sample SMTP configuration
    'gmail' => [
        'host' => 'smtp.gmail.com',
        'port' => 587,
        'username' => 'my@gmail.com',
        'password' => 'secret',
        'className' => 'Smtp',
        'tls' => true
    ]
],

But it gives the following error:
stream_socket_client() [<a href='https://secure.php.net/function.stream-socket-client'>function.stream-socket-client</a>]: unable to connect to tcp://localhost:25 (Connection refused)

I tried to change in the app_local.php:
'EmailTransport' => [
    // Sample Mail configuration
    'default' => [
        'className' => 'Mail',
        'host' => 'localhost',
        'port' => 25,
        'username' => null,
        'password' => null,
        'client' => null,
        'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
    ],
    // Sample SMTP configuration
    'gmail' => [
        'host' => 'smtp.gmail.com',
        'port' => 587,
        'username' => 'my@gmail.com',
        'password' => 'secret',
        'className' => 'Smtp',
        'tls' => true
    ]
],

But then it gives the following error:
Could not send email: unknown

What I'm doing wrong?
