Guest amajorov Posted March 17, 2005 Report Share Posted March 17, 2005 I'm trying to get the mail() function working in PHP. I get a "Call to undefined function mail()" when I try to use it in a PHP script. From what I've read, PHP looks for sendmail when you compile so, if sendmail is on the system path, the PHP compile will find it and roll it into PHP. I didn't have sendmail installed so installed it via RPM. The recompile of PHP didn't seem find sendmail. I'm running Mandrake 10.0 and PHP 5. When I went looking for sendmail I found what looks like some linking that doesn't make a lot of sense. Here it is: in /usr/sbin lrwxrwxrwx 1 root root 21 Mar 16 18:03 sendmail -> /etc/alternatives/mta*-r-x--s--x 1 root mail 692556 Jan 22 2004 sendmail.sendmail* in /etc/alternatives # ls -l mta*lrwxrwxrwx 1 root root 27 Mar 16 18:03 mta -> /usr/sbin/sendmail.sendmail* lrwxrwxrwx 1 root root 42 Mar 16 18:03 mta-aliasesman -> /usr/share/man/man5/aliases.sendmail.5.bz2 lrwxrwxrwx 1 root root 27 Mar 16 18:03 mta-in_libdir -> /usr/sbin/sendmail.sendmail* lrwxrwxrwx 1 root root 23 Mar 16 18:03 mta-mailq -> /usr/bin/mailq.sendmail* lrwxrwxrwx 1 root root 40 Mar 16 18:03 mta-mailqman -> /usr/share/man/man1/mailq.sendmail.1.bz2 lrwxrwxrwx 1 root root 28 Mar 16 18:03 mta-newaliases -> /usr/bin/newaliases.sendmail* lrwxrwxrwx 1 root root 45 Mar 16 18:03 mta-newaliasesman -> /usr/share/man/man1/newaliases.sendmail.1.bz2 lrwxrwxrwx 1 root root 23 Mar 16 18:03 mta-rmail -> /usr/bin/rmail.sendmail* So it looks to me like /usr/sbin/sendmail is pointing to /etc/alternatives/mta which is pointing to /usr/sbin/sendmail.sendmail. What the heck's that about? Here's my $PATH: /sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin When I looked in the compiler.txt in the PHP source directory I found: checking for sendmail... no So it isn't finding sendmail, which I knew but why? It looks to be on the system path. Is there some ownership or permissions issue I don't see? Allen [moved from Software by spinynorman] Quote Link to comment Share on other sites More sharing options...
adamw Posted March 17, 2005 Report Share Posted March 17, 2005 That's the alternatives system, which is a way of smoothly allowing several different programs to provide a certain capability. It's nicked from Debian. Maybe the alternatives system messes up the detection of the php mail thing you're using. MDK has very comprehensive PHP packages, I assume there's a package for the module you're trying to use; have you tried using that package instead? It may be patched to work with the alternatives system. (This is somewhat tentative as I don't do any web development stuff at all, the only bit I'm sure about is the alternatives system). Quote Link to comment Share on other sites More sharing options...
garf Posted March 18, 2005 Report Share Posted March 18, 2005 i think the mail() funtion have to be sent in the http.conf of your web server (i use apache) u uncomment the line and change the path to sendmail Quote Link to comment Share on other sites More sharing options...
Guest amajorov Posted March 18, 2005 Report Share Posted March 18, 2005 (edited) adamw Is there somewhere the "alternatives" system is documented? I've looked for information on how sendmail integrates into Mandrake and haven't had any luck. From what I understand, all that should be necessary for a PHP compile to include sendmail functionality is for the compile to be done with sendmail somewhere on the system path. Well, it is but I still don't get the mail() function to work so something else is going on. garf I found the httpd.conf file but couldn't find anything that even looked like it related to sendmail in the file. Do you have some reference/url you could put up that documents the changes needed to get sendmail working with Apache? Edited March 18, 2005 by amajorov Quote Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted March 18, 2005 Report Share Posted March 18, 2005 Sendmail should work with apache with no problems. Maybe you can try editing /etc/php.ini (or php5.ini if you are using php5) and look for thi line ;sendmail_path = uncomment it by removing the ; from the front of it and put the real path to sendmail there and then restart httpd. Quote Link to comment Share on other sites More sharing options...
adamw Posted March 18, 2005 Report Share Posted March 18, 2005 man update-alternatives should get you started on how the alternatives system works. Quote Link to comment Share on other sites More sharing options...
garf Posted March 19, 2005 Report Share Posted March 19, 2005 garf I found the httpd.conf file but couldn't find anything that even looked like it related to sendmail in the file. Do you have some reference/url you could put up that documents the changes needed to get sendmail working with Apache? <{POST_SNAPBACK}> ighty if you goto sitepoint.com there is a free download of a book called something like "building dynamic webpages with mysql and php" its got a good section on installing and configureing apache/php/mysql im sure its the http.conf file you need, if not illset it up again on my box in the mornin and tell you exactly what is needed Quote Link to comment Share on other sites More sharing options...
Guest amajorov Posted March 22, 2005 Report Share Posted March 22, 2005 Thanks Adam, Qarf. I still haven't figured out why PHP won't find sendmail although I'm beginning to think it has something to do with the update-alternatives system. It seems like it ought to be easy enough. Everything I've read about PHP and sendmail says that if sendmail is on the path you get sendmail functionality. Sendmail is most definitely on my system $_PATH but no joy. I've compiled PHP from source and installed sendmail via RPM which might have something to do with it. I'm assuming that the official, Mandrake RPM of PHP is set up to deal with the alternatives system but that the source install isn't. Unfortunately, having suspicions and knowing what to do about them are two different things. Oh well. Quote Link to comment Share on other sites More sharing options...
Guest anon Posted March 22, 2005 Report Share Posted March 22, 2005 http://phpmailer.sourceforge.net/ Quote Link to comment Share on other sites More sharing options...
Guest amajorov Posted March 24, 2005 Report Share Posted March 24, 2005 PHPMailer doesn't work either but thanks for trying Just to reiterate, I'm running Mandrake 10.0, PHP5 - compiled from source, sendmail installed via RPM and the PHP mail() function doesn't work. Undefined function error. I'd appreciate any assistance. Thanks Quote Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted March 24, 2005 Report Share Posted March 24, 2005 This is everything 'php' i have installed and mail works fine for me: php5-posix-5.0.2-1mdk php5-xml-5.0.2-1mdk php5-dbase-5.0.2-1mdk php-xmlrpc-4.3.8-1mdk libphp_common432-4.3.8-3mdk php5-ini-5.0.2-1mdk libphp5_common5-5.0.2-1mdk php5-dba-5.0.2-1mdk php5-exif-5.0.2-1mdk php5-ftp-5.0.2-1mdk php5-ctype-5.0.2-1mdk php5-cli-5.0.2-1mdk php-ini-4.3.8-1mdk apache2-mod_php5-2.0.50_5.0.2-1mdk php-cli-4.3.8-3mdk php-pear-HTML_Common-1.2.1-3mdk php5-sysvsem-5.0.2-1mdk libc-client-php0-2004-1mdk php-manual-en-4.3.8-1mdk php5-gd-5.0.2-1mdk php5-pcre-5.0.2-1mdk php5-session-5.0.2-1mdk php5-mysql-5.0.2-1mdk php5-ming-5.0.2-1mdk php5-fileinfo-5.0.2_0.2-1mdk php-xml-4.3.8-1mdk php-pear-4.3.8-1mdk php5-recode-5.0.2-1mdk php5-gettext-5.0.2-1mdk php5-sysvshm-5.0.2-1mdk php5-filepro-5.0.2-1mdk php-cgi-4.3.8-3mdk php5-dbx-5.0.2-1mdk php5-yp-5.0.2-1mdk php5-cgi-5.0.2-1mdk Quote Link to comment Share on other sites More sharing options...
Guest amajorov Posted March 31, 2005 Report Share Posted March 31, 2005 Took me a while but I ground my way through the whole list, Steve. A bunch of the list is on my system. A few items aren't but the ones that aren't don't seem to have anything to do with sendmail. Should I install them anyway? The thing that's driving me so nuts is that all the documentation says it ought to be pig simple: If sendmail is on the path then php will find it during a compile and you're done. I think it's some system-related F'up but I'm kind of new to *nix and some of this stuff is confusing. For instance, there's a "mail" user and a "mail" group. But there's also a "mailnull" user and a "mailnull" group. It doesn't take a rocket scientist to figure out this has something to do with the mail but what? The "mail" user has a: primary group of - mail login shell of - /bin/sh home dir of - /var/spool/mail The "mailnull" user has a: primary group of - mailnull login shell of - /dev/null home dir of - / var/spool/mqueue and its status is "locked" There's also a "sendmail" service which shows up as running. Sigh. Quote Link to comment Share on other sites More sharing options...
ddmcse Posted March 31, 2005 Report Share Posted March 31, 2005 (edited) mr Scrimpshire suggested checking the php.ini file . you confirmed that is set correctly ? you need the sendmail path set in php.ini and the outgoing SMTP server to be used if you specify your own server as an outgoing smtp server and you are using an ISP it can appear to be relaying email and the email will fail or atleast not get to where u r sending . check these lines in /etc/php.ini ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). sendmail_path =/usr/sbin/sendmail SMTP = smtp.yourISP.com mine works and i use postfix but the path to sendmail still needs to be there Edited March 31, 2005 by ddmcse Quote Link to comment Share on other sites More sharing options...
Guest amajorov Posted April 1, 2005 Report Share Posted April 1, 2005 Been there, done that. Got the T-shirt. Thanks for trying ddmcse but futzing with the php.ini file was among the first things I tried. Quote Link to comment Share on other sites More sharing options...
ddmcse Posted April 2, 2005 Report Share Posted April 2, 2005 we can't see your logs or the error message exactly and don't know what you've check and not checked . i would seach google for the exact error message . if you're having problems i'm others have had the same problem before you. ii did i quick 1 shot search and see a few leads .. looks like some people using squirrelmail have close to the same error you have . searching google has always given me leads.. that and log files . good luck 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.