Page 1 of 1

php mail

Posted: Sun Feb 15, 2009 12:10 pm
by harinibn
iam trying to send the infrmation from a form to email . I used the following code. but i is not working. could some ne help me with this. I appreciate your help.

Code: Select all

 
<?php 
$to = "you@yoursite.com"; 
$subject = "Contact Us"; 
$email = $_REQUEST['email'] ; 
$message = $_REQUEST['message'] ; 
$headers = "From: $email"; 
$sent = mail($to, $subject, $message, $headers) ; 
if($sent) 
{print "Your mail was sent successfully"; }
else 
{print "We encountered an error sending your mail"; }
?>
 

Re: php mail

Posted: Sun Feb 15, 2009 7:36 pm
by jackpf
An error message or something of the sort would be useful, but I guess this isn't working because mail() doesn't return a value if it fails.
If you do something like this:

Code: Select all

 
<?php
if(!isset($_REQUEST['message']))
{
die('Error. Please revise.');
}
?>
 
for each variable you're getting from the form, then there's a very high chance that mail() will send.
Hope that helped...
Jack.