mail() function problem - works in shell scripts, but not in http

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lu

    mail() function problem - works in shell scripts, but not in http

    Hi,

    I have a redhat 9 linux machine running apache 2.0.47, mysql 4.0.15,
    and php 4.3.4. I have been puzzled by this mail() problem for quite a
    while, could someone please give me some hint on this?

    I configured sendmail with a relay so that all outgoing mails go
    through our organization's exchange mail server:
    DSexchange.doma in.com. The php.ini file specified the path to
    sendmail: "sendmail_p ath= /usr/sbin/sendmail -t -i".

    I can send email out from shell by doing ">mail lsun91125@yahoo .com".
    I also tested a shell script using php mail() function:
    ----------------------------------------------------
    #!/usr/local/php/bin/php -q
    <?php
    $sent=mail("lsu n91125@yahoo.co m", "php email", "test this");
    print "Send=$sent \n";
    ?>
    ----------------------------------------------------
    This works fine too.

    But when I tested the following script on the web, the email cannot be
    sent out. The browser returned with "Send=". There is nothing in the
    mail queue either.
    ----------------------------------------------------
    <?php
    $sent=mail("lsu n91125@yahoo.co m", "php email", "test this");
    print "Send=$sent \n";
    ?>
    ----------------------------------------------------

    Your help is greatly appreciated.

    Lu
  • Pedro Graca

    #2
    Re: mail() function problem - works in shell scripts, but not in http

    Lu wrote:[color=blue]
    > I also tested a shell script using php mail() function:[/color]
    (snip command-line php script)[color=blue]
    > This works fine too.
    >
    > But when I tested the following script on the web, the email cannot be
    > sent out.[/color]
    (snip)


    The default PHP configuration for my Debian machine is that php.ini for
    command-line is different than php.ini for Apache 1.3.29
    The first is in /etc/php4/cgi/php.ini
    and the second in /etc/php4/apache/php.ini

    Confirm your settings for command-line
    /usr/local/php/bin/php -i | grep php\.ini

    and for Apache with the output of <?php phpinfo(); ?>
    --
    --= my mail box only accepts =--
    --= Content-Type: text/plain =--
    --= Size below 10001 bytes =--

    Comment

    • Manuel Lemos

      #3
      Re: mail() function problem - works in shell scripts, but not inhttp

      Hello,

      On 03/10/2004 06:13 PM, Lu wrote:[color=blue]
      > I have a redhat 9 linux machine running apache 2.0.47, mysql 4.0.15,
      > and php 4.3.4. I have been puzzled by this mail() problem for quite a
      > while, could someone please give me some hint on this?
      >
      > I configured sendmail with a relay so that all outgoing mails go
      > through our organization's exchange mail server:
      > DSexchange.doma in.com. The php.ini file specified the path to
      > sendmail: "sendmail_p ath= /usr/sbin/sendmail -t -i".[/color]

      Are you sure you can relay messages from that machine without
      authentication? Usually you need to do that.

      Anyway, you do not need to rely on sendmail to relay messages to a SMTP
      server. You may want to try this class that comes with a wrapper
      function named smtp_mail() that emulates the mail() function, except
      that it lets you configure a SMTP relay server even under Linux and if
      necessary authenticates to let your Exchange server relay your messages:



      You also need this:






      --

      Regards,
      Manuel Lemos

      PHP Classes - Free ready to use OOP components written in PHP
      Free PHP Classes and Objects 2026 Versions with PHP Example Scripts, PHP Tutorials, Download PHP Scripts, PHP articles, Remote PHP Jobs, Hire PHP Developers, PHP Book Reviews, PHP Language OOP Materials


      PHP Reviews - Reviews of PHP books and other products


      Metastorage - Data object relational mapping layer generator

      Comment

      • Lu

        #4
        Re: mail() function problem - works in shell scripts, but not in http

        Thank you all so much for your help!

        I finally figured it out: I was modifying the php.ini file from
        /usr/local/php/lib/ direcotry, but apache needs the
        /usr/local/lib/php.ini file.

        Cheers!

        Lu

        Comment

        Working...