What a problem! I suppose that the code is not the problem. I changed mail func to Qmail-injector function, so everything should be right for Qmail. The script does not return errors. But nothing appears to Qmails logs. From the command line I can send a message with qmail-inject. Here my little form:
<HTML> <HEAD> <TITLE>E-Mail Form</TITLE>
</HEAD> <BODY>
<?php
function qmail_inject($from,$to,$subject,$msg) {
just in case ...
$from = escapeshellarg($from);
change the email address below (returns@fodge.net) to the
address where you wish to receive bounced mail notification
if ( $fh = popen("/var/qmail/bin/qmail-inject -f$from", 'w') ) {
opened qmail-inject
write to it
// My code starts (I could not use the standart \r\n because it does
// not work? with \n it works fine)
$content="Return-Path: ".$from."\n";
$content.="Date: ".date(r)."\n";
$content.="From: ".$from."\n";
$content.="Subject: ".$subject."\n";
$content.="To: ".$to."\n";
$content.=$msg."\n";
//..> My code Ends
fputs ($fh, $content);
need to know what qmail-inject just got hit with?
print '<pre>'. htmlspecialchars($content) .'</pre>';
if ( ($qmail_exit = pclose($fh)) != 0 ) {
woops, qmail didn't like that
return FALSE;
}
return TRUE;
} else
couldn't do anything
return FALSE;
}
// Your E-mail Address
$to = "me@example.com";
if ($ACTION == "send-mail") {
qmail_inject($from,$to,$subject,$msg);
echo "<h2>Thanks for sending me a mail!</h2>\n";
} else {
echo "<h2>Hello! Use this form to send me mail!</h2>\n";
}
?>
<FORM METHOD=POST>
<INPUT TYPE=HIDDEN NAME="ACTION" VALUE="send-mail">
Your E-mail: <INPUT TYPE=TEXT NAME="from"><br>
Message Subject: <INPUT TYPE=TEXT NAME="subject"><p>
Message:<br>
<TEXTAREA NAME="msg" ROWS=5 COLS=50></TEXTAREA><p>
<INPUT TYPE=SUBMIT> * <INPUT TYPE=RESET>
</FORM>
</BODY>
</HTML>