Results 1 to 11 of 11

Thread: Fatal error: Call to undefined function: mail()

  1. #1
    Join Date
    Oct 2003
    Location
    Riyadh
    Posts
    28

    Fatal error: Call to undefined function: mail()

    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.
    Future belong to those who prepare it for today
    Best Hosting Services NASHIRNET WEB HOSTING

  2. #2
    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

  3. #3
    Join Date
    Oct 2003
    Posts
    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 Code:
    mail("tim@domain.net","test","tim@domain.net"); 

  4. #4
    Hello,

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

    John

  5. #5
    Join Date
    May 2003
    Posts
    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

  6. #6
    Join Date
    Oct 2003
    Posts
    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 Code:
    <? echo 'test'?>
    # php index.php
    test
    #

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

  7. #7
    Join Date
    Oct 2003
    Location
    los angeles, cali
    Posts
    23
    I had this same problem, I have no idea what caused it....
    -nick
    Systems Engineer
    Lunarpages.com.


  8. #8
    Join Date
    Oct 2003
    Location
    Riyadh
    Posts
    28

    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.
    Future belong to those who prepare it for today
    Best Hosting Services NASHIRNET WEB HOSTING

  9. #9
    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

  10. #10
    Join Date
    May 2003
    Posts
    251
    that happened to me too. i think per default that function, mail(), is disable (it shouldn't).
    OutPerNet webservices
    www.outper.net
    Cloud shared-dedicated / Colo in Argentina

  11. #11
    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

Similar Threads

  1. Replies: 2
    Last Post: 04-05-2011, 11:04 AM
  2. Fatal error: Call to undefined function: mysqli_connect
    By duke28 in forum General Technical Discussion & Troubleshooting
    Replies: 4
    Last Post: 06-17-2008, 04:55 PM
  3. Replies: 2
    Last Post: 04-28-2008, 03:23 PM
  4. Replies: 0
    Last Post: 08-26-2005, 09:00 AM
  5. Fatal error: Call to undefined function: mail()
    By saeed in forum 3rd Party Software
    Replies: 1
    Last Post: 10-07-2003, 02:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •