CakePHP Mail SMTP Time Out

Hi, firstly sorry for my english, i’m brazilian and i’m learning english and cakephp.

I have an application with cakephp 3 and I’m trying to send email through it.

in app.php I configured like this:

 'EmailTransport' => [
    'default' => [
      'className' => 'Smtp',
      // The following keys are used in SMTP transports
      'host' => '',
      'port' => 587,
      'timeout' => 30,
      'username' => 'login',
      'password' => 'senha',
      'client' => null,
      'tls' => true,
      'url' => env('', null),

in my controller

    public function contato()
      if ($this->request->is('post')) {
        $data = $this->request->getData();

        $ip = getenv('REMOTE_ADDR');

          $email = new Email('default');
          $msg = "Nome: {$data['name']}<br>";
          $msg .= "E-mail: {$data['email']}<br>";
          $msg .= "Telefone: {$data['telefone']}<br>";
          $msg .= "Área de atuação: {$data['area']}<br>";
          $msg .= "Mensagem: <br>";
          $msg .= nl2br($data['message']);

          ->subject('[SITE]: ' . $data['name'])

          $this->request->data = null;

          $this->Flash->success('Message Send.');

but it doesn’t work, it generates the following error in error.log

2022-09-06 13:33:42 Error: [Cake\Network\Exception\SocketException] SMTP timeout.

First, if that’s your real password, you should change it right away, because everyone knows it now.


Second, does this answer your question? (This was the first hit when I googled cakephp office365.) You should be setting the from address to an address that your Office365 login has access to send as. Office365 will not accept messages that claim to be from somewhere else; that’s how spam happens.

What kind web hosting you are using ? Like if its godadday it won’t work, because godadday do not allow to use outbound SMTP.

if other then check SMTP rely status. sometime its hosting/server issue.