img yjgx007

phpBB's Failed Sending Email Errors (and how to resolve)

发表于2004/7/16 10:05:00  1439人阅读

分类: php

Description: This article targets the "failed sending email" error on UNIX and people using PHP's mail() function (not phpBB's SMTP function)
Author: dougk_ff7
Date: Thu Jan 29, 2004 4:15 am
Type: Fix
Keywords: email,sendmail,mail,unix
Category: Installing/upgrading/converting
Recently, I've been playing around with some stuff that uses mail() in PHP, and I know I've hit errors in the past when I've set phpBB to use the mail() function, and I never really figured out why each case was failing. It started when I got the real error from PHP (when another program called mail()) -- "PHP Fatal Error: Call to undefined function mail()" -- looking around for a bit, I found that there are a few things that can cause this. One is simply PHP can't find sendmail, so you need to point it in the right direction using the "sendmail_path" option in php.ini. If that fails to work, you're going to have to do a bit more work. Create a new .php file (for example, phpinfo.php), with only "<?php phpinfo() ?>" (without quotes) in it. Upload this to your server, and view it with your web browser. Look down a bit until you see "sendmail_path" -- I found if this is broken, it usually displays "-t -i" -- the default parameters it uses for sendmail, and nothing else. Ok, so that was kinda pointless. It doesn't tell us very much more. Anyway, now the real reason for creating the phpinfo() file. Please follow these steps *exactly* (or modify slightly for your setup, you'll get the idea):

  • Copy that entire ./configure line up at the top of the phpinfo() page -- it'll make your life much less painful, trust me. Don't worry about the single quotes, they're fine. Just leave them.
  • Check for a working sendmail -- postfix and most other MTAs should provide this, qmail will provide a compatible warpper. Just make sure there's something. /usr/lib/sendmail, /usr/bin/sendmail, and /usr/sbin/sendmail are good bets, as far as I know. If your sendmail is elsewhere, make a symlink back to /usr/sbin/sendmail ("ln -s /path/to/your/sendmail /usr/sbin/sendmail") -- for qmail, that's "ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail"
  • Either grab the latest source of PHP, or find the source you built PHP from (this will require root later on, so if you're on a shared host, see if the problem exists outside of phpBB, and if it does, ask them to work on it for you).
  • If you are using a clean source tree, skip this step. If not, run make clean.
  • Run the ./configure line you just copied, or if you wish, reconfigure php to your liking. Hey, you're going to redo the entire thing, why not do it right?
  • Run make, su to root, and make install.
  • Check php.ini (if you don't know where it is, try "locate php.ini") -- make sure the sendmail_path is correct.
  • Run apachectl stop, followed by apachectl start(ssl)? -- if you use ssl, use startssl, if not, just use start. I found that apachectl restart seems to have some strange quirks, and may just die on you after rebuilding PHP. If you can't find apachectl, try "locate apachectl" or "whereis apachectl" to help you out.
  • Test mail() using a simple script. Unfortunately, I don't have one made. Perhaps [url]php.net[/url] would have an idea?

That's it. Hope this helps someone out there!

Good luck!
0 0



取 消