Is this related to PHP-DB? Anyways, if I understands it correctly is that mail() is working but the client is categorizing the mail received into the SPAM folder.This might means your issue is not longer on that mail(), but on the your mail-client filters. GR mrfroasty nagendra prasad wrote: > Hi all, > > Below is the code that I have coded after replies from all of you. But > before that I want to thank all of you for your help. I have coded the email > code but still it is giving me an error. Please help me. > > <?php > > //sending email script > > $to = "example@xxxxxxxxx"; > $subject = "Email from admin"; > > if ($_POST['submit']) > { > //get data from form > > $name = $_POST['name']; > $message = $_POST['message']; > if ($name&&$message) > { > $namelen = 20; > $messagelen = 300; > if (strlen($name)<=$namelen && strlen($message)<=$messagelen) > { > //everything is ok > > ini_set("SMTP", "smtp.gmail.com"); > > > $to = "example@xxxxxxxxx"; > > $subject = "Email from admin"; > $header = "from: example@xxxxxxxxx"; > > > $body = "Email from $name \n\n $message"; > > > mail($to,$subject,$body,$header); > die(); > } > else > die ("Max length of name is $namelen, and max length for message is 300"); > > } > else > die("you must enter a name"); > } > > ?> > > <html> > <form action='sendemail.php' method='POST'> > Name: <input type='text' name='name' maxlenght='20'><br> > Message: <br><textarea name='message'></textarea><p> > <input type='submit' name='submit' value='Send an email'> > > </form> > > > > </html> > -------------------------------------------------------------------------------------- > > Also I have simplified the code by just using the email() function but the > problem is its sending the mail in the SPAM. The code is below : > > <?php > $to = "example@xxxxxxxxx"; > $subject = "Test mail"; > $message = "Hello! This is a simple email message."; > $from = "example@xxxxxxxxx"; > $headers = "From: $from"; > mail($to,$subject,$message,$headers); > echo "Mail Sent."; > ?> > > -- Extra details: OSS:Gentoo Linux profile:x86 Hardware:msi geforce 8600GT asus p5k-se location:/home/muhsin language(s):C/C++,VB,VHDL,bash,PHP,SQL,HTML,CSS Typo:40WPM url:http://www.mzalendo.net -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php