send mail using mail() in php <p>Hello I am learning php where i came to know mail() function i have tried this code</p> <pre><code>function sendMail() { $to = 'Sohil Desai&lt;sohildesai.2711@gmail.com&gt;'; $from = 'Sohil Desai&lt;sohildesai.2711@hotmail.com&gt;'; $subject = 'Test Mail'; $headers = 'MIME-Version: 1.0'. "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: '.$from . "\r\n"; $headers .= 'X-Mailer: PHP/'.phpversion(); $message = 'This mail is sent for testing.'; $mail = mail($to, $subject, $message, $headers); if (!$mail) { return 'Error occured sending mail.'; } return 'Mail successfully sent.'; } echo sendmail(); </code></pre> <p>I have tested only for gmail, ymail and hotmail.</p> <p>This function sends mail in a spam for gmail &amp; hotmail and it won't send mail to ymail.</p> <p>why it happens??</p> <p>I am using Ubuntu 12.04 &amp; php version 5.3.10.</p> <p>Can anyone help me?? Thanks to halpers in advance..</p>