Page 1 of 1

why the mail can not work?

Posted: Sat Aug 23, 2003 10:27 pm
by lancet2003
The following is the code of text.php

Code: Select all

<HTML>
<HEAD>
<TITLE>E-Mail Form</TITLE>
</HEAD>
<BODY>
<FORM action="hidden.php" method="POST">
Your Name: <INPUT type="text" name="name"><br><br>
Your E-Mail Address: <INPUT type="text" name="email"><br><br>
Message:<br>
<textarea name="message" cols=30 rows=5></textarea><br><br>
<INPUT type="submit" value="Send Form">
</FORM>
</BODY>
</HTML>

the following is the code of hidden.php

Code: Select all

</head>
<body>
<?php
print "Thank you, <b>$_POST&#1111;name]</b>, for your message!<br><br>\n\n";
print "Your e-mail address is: <b>$_POST&#1111;email]</b><br><br>\n\n";
print "Your message was:<br><br>\n\n";
print "$_POST&#1111;message] <br><br>";

//start building the mail string
$msg = "Name:     $_POST&#1111;name]\n";
$msg .= "E-Mail:   $_POST&#1111;email]\n";
$msg .= "Message:  $_POST&#1111;message]\n";

//set up the mail
$recipient = "yuping-wang@tamu.edu";
$subject = "Form Submission Results";
$mailheaders = "From: My Web Site <defaultaddress@yourdomain.com> \n";
$mailheaders .= "Reply-To: $_POST&#1111;email]\n\n";

//send the mail
mail($recipient, $subject, $msg, $mailheaders) or print " could not send mail";
?>
</body>
</html>

when I run the program, why it always shows that "could not send mail"
Thanks

Posted: Sat Aug 23, 2003 10:30 pm
by phice
instead of the " or " statement, use:

Code: Select all

<?php
if(!mail($recipient, $subject, $msg, $mailheaders))
{
// Unable to send
} else {
// Able to send
}
?>

Posted: Sat Aug 23, 2003 10:55 pm
by lancet2003
if(!mail($recipient, $subject, $msg, $mailheaders))
{
print "Unable to send" ;
} else {
print "Ok";
}


Then always shows:
" Thank you, aa, for your message!

Your e-mail address is: bbb

Your message was:

ccc

Unable to send "

Posted: Sun Aug 24, 2003 6:44 am
by volka
is the mail section of the php.ini configured?
[mail function]
; For Win32 only.
SMTP = localhost

; For Win32 only.
sendmail_from = me@localhost.com

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
try it without the additional mail headers. It might be that the MTA accepts neither the unknown From: nor the unkown reply-to: address