form mail

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
<t>
Forum Newbie
Posts: 1
Joined: Fri Feb 18, 2005 8:08 pm

form mail

Post by <t> »

I can't seem to figure out whats wrong with the following script. It keeps telling me "email didnt send", but I can figure out why(no actual errors produced by php). Any ideas would be appreciated



Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<title>Form Test</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
</head> 

<body> 
<form action="Form1.php?post=yes" method="post"> 
<p>Your name: 
   <input type="text" name="name" /> 
</p> 
<p>Your email: 
   <input type="text" name="email" /> 
</p> 
<p>Message:    
   <textarea name="message" id="message"></textarea> 
<input type="submit" />
</form>
<?php 


if ($_GET&#1111;'post'] == 'yes') &#123; 

    $to = "jts3793@hotmail.com";   
    $headers  = "MIME-Version: 1.0\r\n";   
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";   
    $headers .= "From: ".$_POST&#1111;'email']."\r\n";   
    $mail = mail($to, $_POST&#1111;'name'], $_POST&#1111;'message'], $headers);
	 

    if ($mail) &#123; 
        echo "Thank you, we will get back to you as soon as possible <br /> You sent the following information <br />" . $_POST&#1111;'name'] . "<br /> " . $_POST&#1111;'email'] . "<br />" . $_POST&#1111;'name'] . "<br />";  
        echo "<a href="Form1.php?post=no">Display the form</a>";  
        exit; 
    &#125;
		else &#123; 
        echo 'email didnt send'; 
    &#125; 
&#125; 
?>  
</body> 
</html>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

maybe your mail function needs some configuration? Check the error logs to see if something did happen, but wasn't shown. May want to walk through the mail() configuration stuff on php.net as well.
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Hmm may be a server issue. I tested it on my server and it seemed to work fine:

Output:
Thank you, we will get back to you as soon as possible
You sent the following information
asdf
gasdfff@asfffs.com
asdf
Display the form
I know the mail function depends on sendmail being available on your server if you are on a windows machine you may not find this function useful.

http://us3.php.net/manual/en/ref.mail.php

Sorry if I spammed you. LOL :wink:
Post Reply