Fatal error: Call to undefined function: mail()

saeed

Verified User
Joined
Oct 7, 2003
Messages
28
Location
Riyadh
Hi there
I can't send any mail using any PHP script.
Here is the error i get while trying to send a mail..

"PHP Fatal error: Call to undefined function: mail()"

This is only the problem with mail() all other functions are working fine.

Before that my sites was on another server and they were working fine.. yesterday i transferred my sites to a new server using direct admin. but now i m facing this problem... i dono wat's wrong..

where as i have checked phpinfo() stating as:-

sendmail_from = me@localhost.com
sendmail_path = -t -i
SMTP = localhost
smtp_port = 25
(same info as in php.ini)

please help me out in this regard.
 

DirectAdmin Support

Administrator
Staff member
Joined
Feb 27, 2003
Messages
8,961
Hello,

That means /usr/sbin/sendmail didn't exist at the time of the php compile.

1) make sure exim is installed (and /usr/sbin/sendmail exists)
2) recompile php:
Code:
cd /usr/local/directadmin/customapache
./build clean
./build php
John
 

Tim

Verified User
Joined
Oct 8, 2003
Messages
115
Same error

John:

you said i need to do the following:
Code:
cd /usr/local/directadmin/customapache
./build clean
./build php
i tried that, but nothing changed

i still get the error
everything is working fine

only you say that i need to have the next file:

/usr/sbin/sendmail

but i only have: /usr/sbin/sendmail.exim
is that right ?

Fatal error: Call to undefined function: mail() in /home/user/domains/domain.com/public_html/index.php on line 3
PHP:
mail("tim@domain.net","test","tim@domain.net");
 

DirectAdmin Support

Administrator
Staff member
Joined
Feb 27, 2003
Messages
8,961
Hello,

If you don't have /usr/sbin/sendmail, type:
Code:
ln -sf exim /usr/sbin/sendmail
then recompile php as stated above.

John
 

The Prohacker

Verified User
Joined
May 23, 2003
Messages
142
If that doesn't work.. To force compile PHP with the mail function..

Code:
cd /usr/local/directadmin/customapache/php-4.3.3
echo "#define HAVE_SENDMAIL 1" >> main/php_config.h
make
make install
 

Tim

Verified User
Joined
Oct 8, 2003
Messages
115
after i recompiled PHP, IE wants to download all the php files

i checked the addtype's and the modules, everything is like:

<IfDefine HAVE_PHP?>
LoadModule php?_module modules/libphp?.so
</IfDefine>

where the ? reverse to the version.

i tried te disable the <ifddefine> etc etc , but nohting works

if i do in a shell:

PHP:
<? echo 'test'; ?>
# php index.php
test
#

so php does work.... but not with apache, any idea ?
 

saeed

Verified User
Joined
Oct 7, 2003
Messages
28
Location
Riyadh
problem has been solved

Thnx John...

Sorry for late reply as well. It has been fixed on the same day when you reply back the thread. Everything is working fine now. I did all the step you told about and it went all fine. :)
 

DirectAdmin Support

Administrator
Staff member
Joined
Feb 27, 2003
Messages
8,961
Hello,

Remember that after compiling new modules, you have to restart apache in order to use them:
Code:
service httpd restart
In some *rare* cases, there are apache modules where they shouldn't be (left over from previous installs), and apache ends up using a different modules directory, and ignoring everything you do. The proper location is /usr/lib/apache, so if you find some elsewhere, just delete the other directory and try it again.

John
 

outpernet

Verified User
Joined
May 26, 2003
Messages
251
that happened to me too. i think per default that function, mail(), is disable (it shouldn't).
 

DirectAdmin Support

Administrator
Staff member
Joined
Feb 27, 2003
Messages
8,961
Hello,

As mentioned above, the only reason that function won't be included in php is if the file /usr/sbin/sendmail didn't exist beforehand. I've just changed the customapache script to create the link, even if there was an error when installing exim. This will ensure that php will have mail() included. Then if exim wasn't installed, it can be fixed later without having to recompile php.

John
 
Top