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="[email protected]"; $subject="NEW message from"; $headers="From: $name"; $now=date("M d, Y"); $message="$comment ---------------------------- From: $name Sent: $now"; mail($to,$subject,$message,$headers); Link to comment https://forums.phpfreaks.com/topic/57033-simple-but-cant-figure-out-whats-wrong/ 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 Link to comment https://forums.phpfreaks.com/topic/57033-simple-but-cant-figure-out-whats-wrong/#findComment-281749 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. Link to comment https://forums.phpfreaks.com/topic/57033-simple-but-cant-figure-out-whats-wrong/#findComment-281753 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="[email protected]"; $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"; } Link to comment https://forums.phpfreaks.com/topic/57033-simple-but-cant-figure-out-whats-wrong/#findComment-281802 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.