it is the code <?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"; } ?>
Hotmail requires the email to have some specific headers. I don't know which ones by memory though. I'd suggest you have a look at phpmailer. http://phpmailer.sourceforge.net Take a look at the examples. Also set it up to use SMTP to send your mails.
try with this sample code <?php require("class.phpmailer.php"); $mail = new PHPMailer(); $subject = 'Test Mail'; $content = 'Test Mail'; $to = 'to@domain.com'; $mail->From = "u@domain.org"; $mail->FromName = "u"; $mail->AddReplyTo("u@domain.org","u"); $mail->Username = $smtp_username; $mail->Password = $smtp_password; $mail->Host = $smtp_server; $mail->IsHTML(true); $mail->Mailer = "mail"; $mail->CharSet = "utf-8"; $mail->Subject = stripcslashes($subject); $mail->AltBody = " "; $mail->AddAddress($to,'toName'); $mail->Body = $content; $mail->AltBody = ""; if(!$mail->Send()) { echo "Message was not sent <p>"; echo "Mailer Error: " . $mail->ErrorInfo; }else{ echo "ok "; } ?>
Can you specify "not working"? Doesn't it send the mail at all or does it go to the junk folder again? Did you configure the code above correctly?
This construction is very dangerous. Someone can pass a value for "email" which looks like this: \nCc: spamvictim1, spamvictim2, spamvictim3, etc.\n\nBuy Viagra now! and spam the whole universe. They can even use it to send viruses and other malicious attachments. And it will be traced back to your server. Anything that goes into an email header must be meticulously sanitised.
Is the code you posted above exactly the code you used? Or did you modify it for your needs? Can you post the exact code you used, including the HTML form?