Hi everyone. I am facing a problem regarding in my Contact Us form in my first Yii framework application.When i submit a contact us form it shows some php errors mention below or in attachment.Please tell me how i remove these errors.These errors are:
PHP Error
mail() [<a href=‘function.mail’>function.mail</a>]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()
E:\xampp\htdocs\test\protected\controllers\SiteController.php(61)
49 /**
50 * Displays the contact page
51 */
52 public function actionContact()
53 {
54 $model=new ContactForm;
55 if(isset($_POST[‘ContactForm’]))
56 {
57 $model->attributes=$_POST[‘ContactForm’];
58 if($model->validate())
59 {
60 $headers="From: {$model->email}\r\nReply-To: {$model->email}";
61 mail(Yii::app()->params[‘adminEmail’],$model->subject,$model->body,$headers);
62 Yii::app()->user->setFlash(‘contact’,‘Thank you for contacting us. We will respond to you as soon as possible.’);
63 $this->refresh();
64 }
65 }
66 $this->render(‘contact’,array(‘model’=>$model));
67 }
68
69 /**
70 * Displays the login page
71 */
72 public function actionLogin()
73 {
Stack Trace
#0
– E:\xampp\htdocs\test\protected\controllers\SiteController.php(61): mail("khurshidi786@yahoo.com", "Test", "test", "From: mskhurshidi_81@yahoo.com Reply-To: mskhurshidi_81@yahoo.c…")
56 {
57 $model->attributes=$_POST[‘ContactForm’];
58 if($model->validate())
59 {
60 $headers="From: {$model->email}\r\nReply-To: {$model->email}";
61 mail(Yii::app()->params[‘adminEmail’],$model->subject,$model->body,$headers);
62 Yii::app()->user->setFlash(‘contact’,‘Thank you for contacting us. We will respond to you as soon as possible.’);
63 $this->refresh();
64 }
65 }
66 $this->render(‘contact’,array(‘model’=>$model));
#1
– E:\xampp\htdocs\yii\framework\web\actions\CInlineAction.php(50): SiteController->actionContact()
45 $controller=$this->getController();
46 $method=new ReflectionMethod($controller, $methodName);
47 if($method->getNumberOfParameters()>0)
48 return $this->runWithParamsInternal($controller, $method, $params);
49 else
50 return $controller->$methodName();
51 }
52
53 }
#2
– E:\xampp\htdocs\yii\framework\web\CController.php(300): CInlineAction->runWithParams(array("r" => "site/contact"))
295 {
296 $priorAction=$this->_action;
297 $this->_action=$action;
298 if($this->beforeAction($action))
299 {
300 if($action->runWithParams($this->getActionParams())===false)
301 $this->invalidActionParams($action);
302 else
303 $this->afterAction($action);
304 }
305 $this->_action=$priorAction;
#3
– E:\xampp\htdocs\yii\framework\web\CController.php(278): CController->runAction(CInlineAction)
273 * @see runAction
274 */
275 public function runActionWithFilters($action,$filters)
276 {
277 if(empty($filters))
278 $this->runAction($action);
279 else
280 {
281 $priorAction=$this->_action;
282 $this->_action=$action;
283 CFilterChain::create($this,$action,$filters)->run();
#4
– E:\xampp\htdocs\yii\framework\web\CController.php(257): CController->runActionWithFilters(CInlineAction, array())
252 {
253 if(($parent=$this->getModule())===null)
254 $parent=Yii::app();
255 if($parent->beforeControllerAction($this,$action))
256 {
257 $this->runActionWithFilters($action,$this->filters());
258 $parent->afterControllerAction($this,$action);
259 }
260 }
261 else
262 $this->missingAction($actionID);
#5
– E:\xampp\htdocs\yii\framework\web\CWebApplication.php(328): CController->run("contact")
323 {
324 list($controller,$actionID)=$ca;
325 $oldController=$this->_controller;
326 $this->_controller=$controller;
327 $controller->init();
328 $controller->run($actionID);
329 $this->_controller=$oldController;
330 }
331 else
332 throw new CHttpException(404,Yii::t(‘yii’,‘Unable to resolve the request “{route}”.’,
333 array(’{route}’=>$route===’’?$this->defaultController:$route)));
#6
– E:\xampp\htdocs\yii\framework\web\CWebApplication.php(121): CWebApplication->runController("site/contact")
116 foreach(array_splice($this->catchAllRequest,1) as $name=>$value)
117 $_GET[$name]=$value;
118 }
119 else
120 $route=$this->getUrlManager()->parseUrl($this->getRequest());
121 $this->runController($route);
122 }
123
124 /**
125 * Registers the core application components.
126 * This method overrides the parent implementation by registering additional core components.
#7
– E:\xampp\htdocs\yii\framework\base\CApplication.php(155): CWebApplication->processRequest()
150 */
151 public function run()
152 {
153 if($this->hasEventHandler(‘onBeginRequest’))
154 $this->onBeginRequest(new CEvent($this));
155 $this->processRequest();
156 if($this->hasEventHandler(‘onEndRequest’))
157 $this->onEndRequest(new CEvent($this));
158 }
159
160 /**
#8
– E:\xampp\htdocs\test\index.php(13): CApplication->run()
08 defined(‘YII_DEBUG’) or define(‘YII_DEBUG’,true);
09 // specify how many levels of call stack should be shown in each log message
10 defined(‘YII_TRACE_LEVEL’) or define(‘YII_TRACE_LEVEL’,3);
11
12 require_once($yii);
13 Yii::createWebApplication($config)->run();
2011-04-18 11:20:20 Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1 Yii Framework/1.1.7