Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cakephp 3 Unknown Email error

I wanted to ask about sending emails in cakephp3.

I am using cakephp3 docs, and configured everything as example shows.

But, when I try to send mail, this error appears:

Could not send email: unknown

//app.php
'EmailTransport' => [

    'default' => [
        'className' => 'Mail',
        // The following keys are used in SMTP transports
        'host' => 'smtp.gmail.om',
        'port' => 465,
        'timeout' => 30,
        'username' => '[email protected]',
        'password' => 'password',
        'client' => null,
        'tls' => null,
    ],
],

ContactController:

public function contact() {

    if (isset($this->request->data) AND ($this->request->is('post'))) {
        $email = new Email('default');
        if ($email->from(['[email protected]' => 'My Site'])->to('[email protected]')->subject('Hello')->send('Message')) {
            //pr( 'ok');
        }
    }
}

Is this a generic error message (, which may have many reasons, in my opinion)? it has no value in context of debug.

like image 217
user2610146 Avatar asked May 30 '26 01:05

user2610146


1 Answers

You want to use an SMTP server, but you've configured to use the Mail transport!

The className option should be set to Smtp. The host should probably also be different (ssl:// prefixed), or you should enable TLS, please be sure that you read through the questions/answers found with the search linked below.

See also

  • Cookbook > Email > Configuring Transports
  • https://stackoverflow.com/search?q=[cakephp]+gmail
like image 139
ndm Avatar answered Jun 01 '26 17:06

ndm