php mail cannot be sent with smtp.gmail.com
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/36079/php-mail-using-gmail">PHP mail using Gmail</a>  </p>
</blockquote>



<p>code :</p>

<pre><code>&lt;?
    //change this to your email.
    $to = "bhavesh412@gmail.com";
    $from = "bhavesh412@gmail.com";
    $subject = "Hello! This is HTML email";

    //begin of HTML message
    $message = &lt;&lt;&lt;EOF
&lt;html&gt;
  &lt;body bgcolor="#DCEEFC"&gt;
    &lt;center&gt;
        &lt;b&gt;Looool!!! I am reciving HTML email......&lt;/b&gt; &lt;br&gt;
        &lt;font color="red"&gt;Thanks Mohammed!&lt;/font&gt; &lt;br&gt;
        &lt;a href="http://www.maaking.com/"&gt;* maaking.com&lt;/a&gt;
    &lt;/center&gt;
      &lt;br&gt;&lt;br&gt;*** Now you Can send HTML Email &lt;br&gt; Regards&lt;br&gt;MOhammed Ahmed - Palestine
  &lt;/body&gt;
&lt;/html&gt;
EOF;
   //end of message
    $headers  = "From: $from\r\n";
    $headers .= "Content-type: text/html\r\n";

    //options to send to cc+bcc
    //$headers .= "Cc: [email]maa@p-i-s.cXom[/email]";
    //$headers .= "Bcc: [email]email@maaking.cXom[/email]";

    // now lets send the email.
    ini_set("SMTP","smtp.gmail.com");
    ini_set("smtp_port","465");
    mail($to, $subject, $message, $headers);

    echo "Message has been sent....!";
?&gt;
</code></pre>

<p>I am getting below error:</p>

<blockquote>
  <blockquote>
    <p>Warning: mail() [function.mail]: Failed to connect to mailserver at "smtp.gmail.com" port 465, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\testMail.php on line 31</p>
    
    <p>Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\testMail.php on line 33</p>
  </blockquote>
</blockquote>
