title: Sending mail in YII
body: <p>I want to send mails in yii. I have written code for this and it seems to me that the following line is not working.</p>
  
  <pre><code>mail($adminemail, $subject, $message, $headers);
  </code></pre>
  
  <p>my controller:</p>
  
  <pre><code>public function actionIndex()
  {
  $model=new ContactForm;
  if(isset($_POST['ContactForm']))
  {
  $model-&gt;attributes=$_POST['ContactForm'];
  if($model-&gt;validate())
  {
  //$name='=?UTF-8?B?'.base64_encode($model-&gt;name).'?=';
  //Mail
  $subject='Contact Message from '.$model-&gt;name.'';
  $adminemail = Yii::app()-&gt;params['adminEmail'];
  $projectname = Yii::app()-&gt;params['projectname'];
  $headers = "MIME-Version: 1.0\r\n";
  $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
  $headers .= "X-Priority: 3\r\n";
  $headers .= "X-Mailer: PHP". phpversion() ."\r\n";
  $headers .= "Reply-To: ".$model-&gt;name." &lt;{$model-&gt;email}&gt;\r\n"; 
  $headers .= "Return-Path: ".$model-&gt;name." &lt;{$model-&gt;email}&gt;\r\n";
  $headers .= "From: ".$model-&gt;name." &lt;{$model-&gt;email}&gt;\r\n";             
  $message ="&lt;!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'&gt;
  &lt;html xmlns='http://www.w3.org/1999/xhtml'&gt;
  &lt;head&gt;&lt;meta http-equiv='Content-Type' content='text/html; charset=utf-8' /&gt;
  &lt;/head&gt;&lt;body&gt;&lt;div style='width:800px; height:100% auto; border:3px solid #088ef6; border-radius:5px; padding:10px'&gt;
  &lt;table width='800' border='0' cellspacing='0' cellpadding='0'&gt;
  &lt;tr&gt;&lt;td&gt; &lt;a href='".Yii::app()-&gt;homeUrl."' target='_blank'&gt; &lt;img src='".Yii::app()-&gt;homeUrl."images/logo.jpg' width='425' height='65' align='absmiddle' /&gt; &lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;&lt;div style='padding:10px'&gt;&lt;div style='font-size:14px'&gt;&lt;div align='left' style='color:#d50000;   font-weight:bold; font-family:Arial, Helvetica, sans-serif'&gt;Dear Administrator,&lt;/div&gt; &lt;br /&gt;&lt;div align='left' style='font-family:Arial, Helvetica, sans-serif'&gt;Received Contact Message from ".$model-&gt;name.", &lt;br /&gt; 
              Email: ".$model-&gt;email.".&lt;br /&gt; 
              Phone: ".$model-&gt;mobile.".&lt;br /&gt; &lt;br /&gt; 
              ".$model-&gt;message."
              &lt;/div&gt;
  &lt;/html&gt;";
  
  mail($adminemail, $subject, $message, $headers);
  
  $this-&gt;refresh();
  
          }
      }
  
  
      $this-&gt;render('index',array('model'=&gt;$model));
  
  
  }
  </code></pre>
  
  <p>Is there any problem with my yii code, or should any changes be made for my server lamp settings</p>