Yii Framework Forum: Exception 'cexception' With Message 'property "cconsoleapplication.mail" Is Not Defined. - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Exception 'cexception' With Message 'property "cconsoleapplication.mail" Is Not Defined. Rate Topic: -----

#1 User is offline   coolPhp 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 15-December 10

Posted 15 February 2013 - 07:57 AM

Hi All

I am trying to send emails via a cron using yii

Can someone please help me with this error

exception 'CException' with message 'Property "CConsoleApplication.mail" is not defined.' in ......\framework\base\CComponent.php:174 Stack trace:
#0 .....\framework\base\CModule.php(483): CComponent->__set('mail', Array)
#1 .....\framework\base\CApplication.php(144): CModule->configure(Array)
#2 .....\framework\YiiBase.php(127): CApplication->__construct('file location...')
#3 .....\framework\YiiBase.php(115): YiiBase::createApplication('CConsoleApplica...', 'file location...')
#4 .....\console.php(13): YiiBase::createConsoleApplication('file location...')
#5 {main}

Console.php

$yii=dirname(__FILE__).'/../framework/yii.php';
$config=dirname(__FILE__).'/protected/config/Config.php';
defined('YII_DEBUG') or define('YII_DEBUG',true);
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);

require_once($yii);
Yii::createConsoleApplication($config)->run();


Config.php
'mail' => array(
	  'class' => 'ext.mail.YiiMail',
	  'transportType' => 'smtp',
		'transportOptions'=>array(
			'host'=>'smtp.gmail.com',
			'encryption'=>'ssl', // use ssl
			'username'=>'username@gmail.com',
			'password'=>'password',
			'port'=>465, // ssl port for gmail
		),
	  'viewPath' => 'application.views.mail',
	  'logging' => true,
	  'dryRun' => false
	  ),


dairyemailsendCommand.php
class DairyemailsenderCommand extends CConsoleCommand{
    public function getHelp() {
        echo "Checks dairy and sends emails when dairy items are due.";
    }
    
    public function run($args) {

                
                
               $name = date('M')."_dairy_emails_{$d['user']}";

			   Yii::import('ext.yii-mail.YiiMailMessage');
				$message = new YiiMailMessage;
				$message->setBody('test', 'text/html');
				$message->addTo('toemailaddress');
				$message->from = Yii::app()->params['adminEmail'];
				Yii::app()->mail->send($message);


    }
}

0

#2 User is offline   Maciej Li┼╝ewski 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 862
  • Joined: 02-July 10
  • Location:Central Poland

Posted 15 February 2013 - 08:32 AM

maybe 'mail' configuration shuold be in 'components' section?
red
0

#3 User is offline   lkg0dzre 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 13-January 11

Posted 03 May 2017 - 11:52 AM

It was same error in my case.
My error that I changed a wrong config file. When I changed right file it started to work.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users