Mailer Extension in Console

Hi,

I am having trouble executing the mailer extension in console.

here is my console config




return array(

        'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',

        'name'=>'Burban Console',

        'components'=>array(

			'db'=>array(

				'connectionString' => 'mysql:host=localhost;dbname=project',

				'emulatePrepare' => true,

				'username' => '---',

				'password' => '-----',

				'charset' => 'utf8',

			),

			'mailer' => array(

		      	'class' => 'application.extensions.mailer.EMailer',

		      	'pathViews' => 'application.views.email',

		      	'pathLayouts' => 'application.views.email.layouts'

		   ),

        ),

    	'import'=>array(

			'application.models.*',

			'application.components.*',

		),

);



and here is my console code




class StockLowCommand extends CConsoleCommand

{

	public $verbose=true;

	public function actionCheck()

	{

		$sql = "SELECT name,stock,min_level,stock_flag 

				FROM products p 

				WHERE stock <= min_level AND stock_flag = 1 

				ORDER BY name";

		

    	        $connection = Yii::app()->db;

		$command = $connection->createCommand($sql);

		$products = $command->queryAll();

		//print_r($products);

		if ($products)

		{

			//send email to owner

	                Yii::app()->mailer->IsHTML();

	                Yii::app()->mailer->CharSet = 'UTF-8';

	                Yii::app()->mailer->From = '------';

	                Yii::app()->mailer->FromName = '---------';

	                Yii::app()->mailer->Sender = '-------';

	                Yii::app()->mailer->AddAddress('-------');

	                Yii::app()->mailer->Subject = '----------';

	                Yii::app()->mailer->GetView(

	        	     'stock_low',

	        	     array(

	        		'products'=>$products,

	        	     ),

	       		     'email_template'

	       	        );

	                if (Yii::app()->mailer->Send())

	                {

		             

	                }

		}	

	}

}



when i run console I get the error class ‘PHPMailer’ does not have a method ‘getViewFile’ however I can not for the life of me figure out what is going wrong here. I am very much a yii newb. help is appreciated.

solved this by creating a new method in the Email class:




public function getViewConsole($view, $vars = array(), $layout = null)

{

   	$controller = new CController('project');

      	$body = $controller->renderInternal(Yii::app()->basePath.'/views/email/'.$view, array_merge($vars,array('content'=>$this->_myMailer)), true);

      	if ($layout === null) 

      	{

         	$this->_myMailer->Body = $body;

      	}

      	else 

      	{

         	$this->_myMailer->Body = $controller->renderInternal(Yii::app()->basePath.'/views/email/layouts/'.$layout, array('content'=>$body), true);

      	}

   }



Hi,

I have the same problem.

We cant access a controller form view using console app, so how you solve it on EMailer?