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' => 'smtp.office365.com',
'port' => 587,
'timeout' => 30,
'username' => 'login',
'password' => 'senha',
'client' => null,
'tls' => true,
'url' => env('smtp.office365.com', 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']);
$email->from([$data['email']=>$data['name']])
->replyTo([$data['email']=>$data['name']])
->to('email@corporation.com.br')
->subject('[SITE]: ' . $data['name'])
->emailFormat('html')
->send($msg);
$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.