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.