title: Sending mail via php script using wamp server
body: <p>I am using WAMP server 2.4. I want to send a mail to my gmail account. The code I used for the  same is given below. I read some forums and they suggested me to make changes in php.ini file.But it is not a permanent solution.Also some suggested that mail() does not work for gmail ? Is there some solution to this? </p>
  
  <pre><code>       &lt;?php
        //Checking if entries are ok 
        if(isset($_POST['submit']))
        {
  
           if(isset($_POST['username']))
           $id = $_POST['username'];
  
           else 
           echo "Cannot be blank";
  
           //ensuring mail goes to registered user
           $query="SELECT * FROM table1 WHERE id = '$id' ";
           $result= mysql_query($query,$con);
  
  
           if (!($result) )
           {
              die('Error: ' . mysql_error($con));
           }
  
           else
           {
  
                $values = mysql_fetch_array($result);
           }
  
         // Sending mail...
           if(mysql_num_rows($result)== 1)
           {
            if(isset($_POST['email']))
            $to= $_POST['email'];
                else
                echo "invalid email";
                $msg = 'Name :' .$values['name'] ."\n"
                      .'Id:' .$values['id']."\n"
                      .'Email:' .$values['email']."\n"
            ."Your password is:" . $values[password];
  
              mail($to,"Forget your Password",$msg);
              header('location: sent_mail.php');
  
  
      }
          else 
          echo "Verify your username again";
  }
      else{
      echo "sending failed";
      header('location: forget_password.php');
      exit(0);
  }
  </code></pre>