Automatic email to admin

Hey,

If new user register my site then automatic email to admin. How can I do this?

Here is my register controller

public function actionRegister()

{


	$register=new User;


	if(isset($_POST['User']))


	{


		$register->attributes=$_POST['User'];


		if($register->validate())


		{


			$register->save();


				


			Yii::app()->user->setFlash('register','Thank you for registering.  Please check your email for instructions.');


			$this->refresh();


		}


	}


	$this->layout='initial';


	$this->render('register',array('register'=>$register));


}

Please put code into [ code ] tags next time for better reading.

You can use a mail extension like this one. Then you can do:




...


$register->save();


$email = Yii::app()->email;

$email->to = 'someone@example.com';

$email->subject = '...';

$email->message = '...';

$email->send();


Yii::app()->user->setFlash('register','Thank you for registering. Please check your email for instructions.');


$this->refresh();


...



SOrry for that. I got this error

CException

Description

Property "CWebApplication.email" is not defined.

/yii/framework/base/CModule.php(93)

This is my extension. I’m writing a new mail extension which will be much better. You are getting that error because you did not configure it, see docs:

http://www.yiiframework.com/extension/email/#doc