0

I have to implement send mail functionality by using normal php not Smtp in cakephp 3.5.

I have to send html testingreport.ctp that I have put under Template/Email/html.

Below I have added controller and app.php code.

I am getting error Transport config "Mail" is missing.

What I am missing here to send the mail?

//app.php
'EmailTransport' => [
    'default' => [
        'className' => 'Mail',
        // The following keys are used in SMTP transports
        'host' => 'localhost',
        'port' => 25,
        'timeout' => 30,
        'username' => 'user',
        'password' => 'secret',
        'client' => null,
        'tls' => null,
        'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
    ],
],
'Email' => [
    'default' => [
            'log' => true,
            'transport' => 'Mail',
            'emailFormat'=>'html',
            'charset' => 'utf-8',
            'headerCharset' => 'utf-8',
    ],
],


 // controller
$email = new Email('default');
    $email
    ->transport('testingreport','testingreport')
    ->from(['dkvastrakar18@gmail.com' => 'dkvastrakar18@gmail.com'])
    ->to('dkvastrakar18@gmail.com')
    ->subject('subjects')
    ->emailFormat('html')
    ->viewVars($testRequestDet)
    ->send('sendmail');

1 Answers1

1

The email profiles transport configuration option is ment to point to an entry in the EmailTransport configuration, not to an email transport class, the latter is configured via the className option in the specific transport configuration.

Long story short:

'transport' => 'Mail'

should be:

'transport' => 'default'

See also

ndm
  • 59,784
  • 9
  • 71
  • 110