lefthook Posted January 10, 2003 Report Share Posted January 10, 2003 Hi! I just downloaded PHP greeting cards script to make Ecards service on my server, but it cannot connect to my mail server. I have Qmail working with proper sendmail substitute link. Here is a little part of mail func.: function mymail($to, $subject, $message, $headers){ <snip> $mailer = popen ("/usr/sbin/sendmail -t -i -f$from","w"); fwrite ($mailer,"To: $to $headers Subject: $subject $message "); pclose ($mailer); return 1; } I just don't get any logs that it tried to connect to mail server. original mail func. was normal: mail($recipientemail,"E-Greeting Card from $sendername",$notification,"From: $sendername <$senderemail>nReply-To: $senderemail"); Which I just changed to mymail. With mail I got errors. With mymail it says ok, but never connects to mailserver. Where from to start to find the error? Quote Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted January 11, 2003 Report Share Posted January 11, 2003 Maybe this'll help: http://php.root.lu/manual/tr/function.mail.php I'm no PHP expert, but it did say something something about '...make sure there are no newline characters in To or From fields or the mail may not send properly' and also that /r/n works in some transfer agents, but others just need /n to separate headers. Also, maybe this page will help:http://www.php.net/manual/en/ref.mail.php What errors did you get with mail()? Quote Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted January 11, 2003 Report Share Posted January 11, 2003 On the second url one of the hints was "29-May-2002 01:15 I use qmail, and have found that mail() will return TRUE even if there is no valid email address in the To parameter. If you're having problems getting mail() to work with qmail, double-check that the output from your script produces a valid email message before looking further!" I don't know why it wouldn't even show trying to connect to the server. Quote Link to comment Share on other sites More sharing options...
lefthook Posted January 12, 2003 Author Report Share Posted January 12, 2003 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 rn because it does // not work? with n it works fine) $content="Return-Path: ".$from."n"; $content.="Date: ".date®."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> Quote Link to comment Share on other sites More sharing options...
lefthook Posted January 12, 2003 Author Report Share Posted January 12, 2003 Well, things start to clear. My Apache PHP has a chroot installation, so at last I looked /var/logs/error_log: sh: /var/qmail/bin/qmail-inject: No such file or directory sh: /bin/qmail-inject: No such file or directory sh: /var/www/usr/bin/qmail-inject: No such file or directory sh: /bin/qmail-inject: No such file or directory I made a link: sh: /var/qmail/bin/qmail-inject: Too many levels of symbolic links I think there is problem with chroot & links. I'm quite a newbie with this chroot. perhaps I should move this question: How to link correctly chroot binaries outside or is it possible? I have: /var/qmail/bin/ chroot: /var/www/: bin var apache usr etc.. & so on.... 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.
Note: Your post will require moderator approval before it will be visible.