php mail() issues

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

    #1

    php mail() issues

    Apologies if this has been covered before - please slap me and point me in
    the right direction if so - I've limited experience of PHP so possibly
    missed something obvious

    System is a Fedora core 5 system with Apache, PHP 5.1.4 and sendmail 8.13,
    more or less a clean install. Sendmail has been configured to point to my
    ISP provider, masqerade mail and send via them. This works fine, mail comes
    through with the correct headers if I invoke mail from the linux command
    prompt.

    Cannot get mailing functions from Wordpress 2.2 working. Looking through
    the code, I see it uses mail()

    Trying a real simple example like this...

    <? phpinfo();
    mail('mail@myad dress.com','tes t','message'); ?>

    also fails to work - the php info page is put up as expected but no bounced
    mail, no mail comething through, nothing. Is this the correct way of doing
    things - should mail be coming through with the code above? php.ini appears
    to be set up correctly to point to seendmail - has the right path, has r-x
    permission on the binary etc.

    Thanks in advace.

    Chris.
  • Chris

    #2
    Re: php mail() issues

    On Tue, 30 May 2006 11:46:33 -0700, Michael Vilain wrote:
    [color=blue]
    > In article <aecj6usyekm4$. 1n1hbbad971wh.d lg@40tude.net>,
    > Chris <ngfb@chris-street.demon.co .uk> wrote:
    >[color=green]
    >> Apologies if this has been covered before - please slap me and point me in
    >> the right direction if so - I've limited experience of PHP so possibly
    >> missed something obvious
    >>
    >> System is a Fedora core 5 system with Apache, PHP 5.1.4 and sendmail 8.13,
    >> more or less a clean install. Sendmail has been configured to point to my
    >> ISP provider, masqerade mail and send via them. This works fine, mail comes
    >> through with the correct headers if I invoke mail from the linux command
    >> prompt.
    >>
    >> Cannot get mailing functions from Wordpress 2.2 working. Looking through
    >> the code, I see it uses mail()
    >>
    >> Trying a real simple example like this...
    >>
    >> <? phpinfo();
    >> mail('mail@myad dress.com','tes t','message'); ?>
    >>
    >> also fails to work - the php info page is put up as expected but no bounced
    >> mail, no mail comething through, nothing. Is this the correct way of doing
    >> things - should mail be coming through with the code above? php.ini appears
    >> to be set up correctly to point to seendmail - has the right path, has r-x
    >> permission on the binary etc.
    >>
    >> Thanks in advace.
    >>
    >> Chris.[/color]
    >
    > What's the setting for "sendmail_p ath" in your php.ini file?[/color]

    /usr/sbin/sendmail -t -i

    You can see the entire output here if that helps any more.



    Thanks.

    Comment

    • Chris

      #3
      Re: php mail() issues

      On Tue, 30 May 2006 12:26:14 -0700, Michael Vilain wrote:
      [color=blue][color=green][color=darkred]
      >>>
      >>> What's the setting for "sendmail_p ath" in your php.ini file?[/color]
      >>
      >> /usr/sbin/sendmail -t -i
      >>
      >> You can see the entire output here if that helps any more.
      >>
      >> http://80.176.79.35/phpinfo.php
      >>
      >> Thanks.[/color]
      >
      > And what happens when you type
      >
      > /usr/sbin/sendmail -t -i mail@myaddress. com
      > Subject: test
      > message
      > ^D
      >
      > in a shell?[/color]

      That works fine, also works if I run mail from the shell and send a mail
      from in there. I think that sendmail is setup OK (but could be wrong)[color=blue]
      >
      > If that fails, try using
      >
      > /usr/sbin/sendmail -t -v -i
      >
      > instead.[/color]

      Do you mean from the command line or modify the setting in php.ini? I've
      changed it in php.ini - still no joy I'm afraid.

      I don't need any extra rpm's for my PHP installation do I? My understanding
      was that all I needed was the base php for mail - I have that and php-mysql
      for the database backend

      Comment

      • Chris

        #4
        Re: php mail() issues

        On Tue, 30 May 2006 16:05:31 -0700, Michael Vilain wrote:
        [color=blue]
        > In article <11u9xxz5w7gx6$ .ye0g6zklx2ir.d lg@40tude.net>,
        > Chris <ngfb@chris-street.demon.co .uk> wrote:
        >[color=green]
        >> On Tue, 30 May 2006 12:26:14 -0700, Michael Vilain wrote:
        >>[color=darkred]
        >>>>>
        >>>>> What's the setting for "sendmail_p ath" in your php.ini file?
        >>>>
        >>>> /usr/sbin/sendmail -t -i
        >>>>
        >>>> You can see the entire output here if that helps any more.
        >>>>
        >>>> http://80.176.79.35/phpinfo.php
        >>>>
        >>>> Thanks.
        >>>
        >>> And what happens when you type
        >>>
        >>> /usr/sbin/sendmail -t -i mail@myaddress. com
        >>> Subject: test
        >>> message
        >>> ^D
        >>>
        >>> in a shell?[/color]
        >>
        >> That works fine, also works if I run mail from the shell and send a mail
        >> from in there. I think that sendmail is setup OK (but could be wrong)[color=darkred]
        >>>
        >>> If that fails, try using
        >>>
        >>> /usr/sbin/sendmail -t -v -i
        >>>
        >>> instead.[/color]
        >>
        >> Do you mean from the command line or modify the setting in php.ini? I've
        >> changed it in php.ini - still no joy I'm afraid.
        >>
        >> I don't need any extra rpm's for my PHP installation do I? My understanding
        >> was that all I needed was the base php for mail - I have that and php-mysql
        >> for the database backend[/color]
        >
        > I'm running php on a Macintosh, so I can't comment on your specific
        > setup. When you say "it doesn't work", what happens? What status does
        > mail("mail@myad dress.com","sub ject", "body") return? What's in your log
        > for sendmail traffic, where ever you have it configured? Is it just not
        > working from inside php or does it actually go to sendmail, then fail?
        > What about the http log file for touching that page?[/color]

        I don't think it was even getting as far as sendmail. Nothing in the logs,
        and no error codes etc were returned. In order to see if there was a
        problem I uninstalled PHP and then reinstalled all the required RPM's and
        libraries - it now seems to work just fine and dandy. Most bizzare - still
        no idea *why* it didn't work!

        Thanks for all your help and encouragement though - I was ready to revert
        back to my old windows box to run this until I found the answer![color=blue]
        >
        > [just some SWAGs...][/color]

        Comment

        • R. Rajesh Jeba Anbiah

          #5
          Re: php mail() issues

          Chris wrote:
          <snip>[color=blue]
          > Cannot get mailing functions from Wordpress 2.2 working. Looking through
          > the code, I see it uses mail()[/color]
          <snip>

          FWIW, there was a bug in mail() function and I don't think it's get
          fixed. So, when sending mail with mail() function, it will get rejected
          because of syntax error when sensitive servers receive it (eg, Yahoo).
          So, try sending mail to different domains.

          --
          <?php echo 'Just another PHP saint'; ?>
          Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

          Comment

          • ctclibby

            #6
            Re: php mail() issues


            Chris wrote:
            [snip]
            [color=blue]
            > Trying a real simple example like this...
            >
            > <? phpinfo();
            > mail('mail@myad dress.com','tes t','message'); ?>[/color]

            Hi Chris.

            I had problems with this also. Don't know if my solution will work or
            not, but. Here is the code I used. Note that it is pieces of stuff
            that I played with until it worked. Your mileage may vary.
            <?php
            include("DB.php ");
            .....
            $MailTo = 'emailname@doma inname.tld';
            $Subject = 'Some subject here';
            $MailBody = 'What ever is the text you wish to send';
            $headers = "From: me@mydomain.tld";
            .....
            ?>
            I fussed with this for a few hours until I found that 'header' stuff.
            I then wrapped it in an 'if' statement.

            if(mail($MailTo , $Subject, $MailBody, $headers) ) {
            do something here.
            } else {
            oooops. do something drastic here
            }

            Hope that helps

            todh

            Oh FC5, php 5.14, sendmail 8.13.latest

            Comment

            Working...