neel
(Kazi Neel)
January 27, 2010, 6:10pm
1
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));
}
Y11
(Y!!)
January 27, 2010, 6:22pm
2
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();
...
neel
(Kazi Neel)
January 27, 2010, 7:37pm
3
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)
jonah
(Poppitypop)
January 28, 2010, 2:03am
4
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