acidglitter Posted June 25, 2007 Share Posted June 25, 2007 I'm trying to get a contact page to work, and this is the code I'm using, but its not reaching my email for some reason.. Does anyone see whats wrong with this? $name=$_POST['name']; $email=$_POST['email']; $comment=$_POST['comment']; $to="myemail@hotmail.com"; $subject="NEW message from"; $headers="From: $name"; $now=date("M d, Y"); $message="$comment ---------------------------- From: $name Sent: $now"; mail($to,$subject,$message,$headers); Quote Link to comment Share on other sites More sharing options...
sKunKbad Posted June 25, 2007 Share Posted June 25, 2007 Are you sure your server is set up right? If you are using shared hosting, then you might call your host and ask about sending mail from php. In one instance, I had to use this code to make sending mail possible: ini_set("SMTP","mail.mysite.com"); // this being my server's SMTP outgoing server // yours could be smtp.yourdomain.com ini_set("smtp_port","25"); // you might have a different port number for SMTP Quote Link to comment Share on other sites More sharing options...
AndyB Posted June 25, 2007 Share Posted June 25, 2007 Two suggestions: #1 - avoid using 'free' email addresses since they routinely dump email with less than perfect and complete headers #2 - check the php manual to see what headers you need to use. Yours is woefully short of what's needed. Quote Link to comment Share on other sites More sharing options...
suma237 Posted June 25, 2007 Share Posted June 25, 2007 Try this code $name=$_POST['name']; $email=$_POST['email']; $comment=$_POST['comment']; $to="myemail@hotmail.com"; $subject="NEW message from"; $headers="From: $name"; $now=date("M d, Y"); $message="$comment ---------------------------- From: $name Sent: $now"; $ok=mail($to,$subject,$message,$headers); if($ok==1) { echo"message sucessfully send"; }else{ echo"Error!Try again"; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.