[SOLVED] Use CEmailLogRoute::sendEmail() in view

How can i use CEmailLogRoute::sendEmail() inside my view?

in my view


<?php CEmailLogRoute::sendEmail('bas@lustgraaf.nl', 'Foute DT locatie', 'DaytripId: ' . $daytrip->IdDaytrip); ?>

error:

Fatal error: Call to protected method CEmailLogRoute::sendEmail() from context ‘CBaseController’ in **/views/search/_gmaps.php</b> on line 34

I think you have to instantiate the mail log route.


<?php 

$mailRoute= new CEmailLogRoute;

$mailRoute->sendEmail('bas@lustgraaf.nl', 'Foute DT locatie', 'DaytripId: ' . $daytrip->IdDaytrip); ?>




I didn’t tested, is just the first stuff I am doing when I receive this kind of error.

CException

Description

CEmailLogRoute does not have a method named "sendEmail".

As stated in the doc, this method is protected, you cannot call in the controller.

It seems that you should configure this mailer in the config/main and then logging on it.

Sorry for my first answer, I didn’t read it carefully.

ah i see. thank you!

Edit your config:




    'components' => array(

        'log' => array(

            'class' => 'CLogRouter',

            'routes' => array(

                array(

                    'class' => 'CEmailLogRoute',

                    'levels' => 'error',

                    'emails' => 'user@domain.com',

                ),

            ),

        ),

    ),






Yii::log('message' 'error');



see also: http://www.yiiframework.com/doc/guide/1.1/en/topics.logging