Hi
This problem has been bugging me for days and I can’t get to the bottom of it.
The contact page on my site which is the default contact page that comes out of the box with Yii installation sends it’s email twice. I’m having the same problem using the User Control module but only on the ‘reset password’ page not on the registration page.
I’ve tried all kinds of things to track it down but no luck. I’ve used static count variables to see if the mail function was being called twice somehow but it’s not. It’s not the server because the registration page is fine and I can’t see any real differences.
Here’s the code in the contact action (i commented out refresh in case that was causing it but no change)…
public function actionContact()
{
Yii::app()->params['activePage']='nobutton';
Yii::app()->params['pageTitle']='Contact Us';
$this->pageTitle = Yii::app()->name." - Contact Us";
$model=new ContactForm;
if(isset($_POST['ContactForm']))
{
$model->attributes=$_POST['ContactForm'];
if($model->validate())
{
$message = $model->name."\r\n\r\n".$model->body;
$headers="From: {$model->email}\r\nReply-To: {$model->email}";
mail(Yii::app()->params['adminEmail'],$model->subject,$message,$headers);
Yii::app()->user->setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible.');
//$this->refresh();
}
}
$this->render('contact',array('model'=>$model));
}
Anybody else have this problem and if so how did you solve it?
Thanks in advance
Lux