Yii Framework Forum: Default Contact Page Sending Two Emails - Yii Framework Forum

Jump to content

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

Default Contact Page Sending Two Emails Rate Topic: -----

#1 User is offline   luxinterior 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 52
  • Joined: 27-March 12
  • Location:Philippines

Posted 18 July 2012 - 11:12 PM

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
0

#2 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 3,417
  • Joined: 16-February 11
  • Location:Japan

Posted 19 July 2012 - 12:14 AM

It seems to me the problem with "favicon.ico".

http://www.yiiframew...mes-in-one-load
0

#3 User is offline   luxinterior 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 52
  • Joined: 27-March 12
  • Location:Philippines

Posted 19 July 2012 - 12:23 AM

Hi

Thanks for the response.

If indeed it's a problem with the browser and favicon what would be the solution?

The other thing that's odd is it never happens on the registration page but always happens on contact and reset password pages. I just tried the contact page in Opera and the same thing happened. Two emails received :(

Lux
0

#4 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 3,417
  • Joined: 16-February 11
  • Location:Japan

Posted 19 July 2012 - 12:41 AM

View Postluxinterior, on 19 July 2012 - 12:23 AM, said:

If indeed it's a problem with the browser and favicon what would be the solution?

If you don't have favicon.ico in your web root, then just place it.
Probably even an empty file will do.
It might not be the favicon.ico but some other missing file that your page is trying to load.
Check if there's a loading error using your browser's developer tool.

View Postluxinterior, on 19 July 2012 - 12:23 AM, said:

The other thing that's odd is it never happens on the registration page but always happens on contact and reset password pages.

The registration action will alter the user's state, so that the 2nd call to that action will be ignored or canceled.
But in contact and reminder actions, the user's state will remain the same and the 2nd call will be processed normally.
0

#5 User is offline   luxinterior 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 52
  • Joined: 27-March 12
  • Location:Philippines

Posted 19 July 2012 - 01:46 AM

Hi

I already had a favicon.ico in the root so I don't think it's that.

I've also confirmed that the function is being called twice in both firefox and opera.

Still no idea what could be causing it to be called twice though.

Lux

PS: No errors being shown in firebug either.

PPS: Thought I'd solved it when removing the 'apple-icon' lines appeared to solve it but the problem re-appeared shortly after so still looking for a solution.
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