mail() error handling

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

    mail() error handling


    I use mail() for a musician's mailing list script that suddenly started
    having problems after many months of working flawlessly. The code fragment
    is:

    if (mail($To,$Subj ect,$Body,$Head ers,$Param))
    {
    print("The message was sent to:<p>$HTML_BCC <br><hr><h3>Com pleted
    OK</h3><p>\n");
    }
    else
    {
    print("<font color=\"#ccff66 \">There was a problem and the
    message was probably not sent.</font><br>\n");
    }


    How can I find out what is causing the error? I thought there were
    built-in error number and error description messages, but a search of the
    manual at php.net does not come up with anything.

    Pierre
    --
    Pierre Jelenc | H o m e O f f i c e R e c o r d s
    | * Ethan Lipton * Marwood * The Cucumbers *
    T h e G i g o m e t e r | * Switchblade Kittens * Pawnshop *
    www.thegigometer.com | www.homeofficerecords.com
  • Manuel Lemos

    #2
    Re: mail() error handling

    Hello,

    On 12/02/2003 08:47 PM, Pierre Jelenc wrote:[color=blue]
    > I use mail() for a musician's mailing list script that suddenly started
    > having problems after many months of working flawlessly. The code fragment
    > is:
    >
    > if (mail($To,$Subj ect,$Body,$Head ers,$Param))
    > {
    > print("The message was sent to:<p>$HTML_BCC <br><hr><h3>Com pleted
    > OK</h3><p>\n");
    > }
    > else
    > {
    > print("<font color=\"#ccff66 \">There was a problem and the
    > message was probably not sent.</font><br>\n");
    > }
    >
    >
    > How can I find out what is causing the error? I thought there were
    > built-in error number and error description messages, but a search of the
    > manual at php.net does not come up with anything.[/color]

    The mail function will hardly give you any information. You would better
    check the your mailer logs or send the messages directly to your
    recipients SMTP server and see what it responds. In this case you may
    want to try this class that comes with a subclass for interfacing with
    the recipient SMTP server to perform direct deliveries.



    You also need this:




    --

    Regards,
    Manuel Lemos

    Free ready to use OOP components written in PHP
    Free PHP Classes and Objects 2025 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


    Comment

    • Tim Van Wassenhove

      #3
      Re: mail() error handling

      On 2003-12-02, Pierre Jelenc <rcpj@panix.com > wrote:[color=blue]
      >
      > I use mail() for a musician's mailing list script that suddenly started
      > having problems after many months of working flawlessly. The code fragment
      > is:[/color]

      before the if put in this
      echo "TO: $To SUBJECT: $Subject";

      If it outputs "TO: SUBJECT: " then i think you're php version has
      changed, and has register_global s=off now.
      [color=blue]
      > if (mail($To,$Subj ect,$Body,$Head ers,$Param))[/color]


      --
      verum ipsum factum

      Comment

      • Pierre Jelenc

        #4
        Re: mail() error handling

        Tim Van Wassenhove <euki@pi.be> writes:[color=blue]
        > On 2003-12-02, Pierre Jelenc <rcpj@panix.com > wrote:[color=green]
        > >
        > > I use mail() for a musician's mailing list script that suddenly started
        > > having problems after many months of working flawlessly. The code fragment
        > > is:[/color]
        >
        > before the if put in this
        > echo "TO: $To SUBJECT: $Subject";
        >
        > If it outputs "TO: SUBJECT: " then i think you're php version has
        > changed, and has register_global s=off now.
        >[color=green]
        > > if (mail($To,$Subj ect,$Body,$Head ers,$Param))[/color][/color]

        No, no problem there. In further tests we found that some of the mail does
        go through sometimes, but in unpredictable manner. Unfortunately I don't
        have access to the machine's configuration, it is a shared machine and to
        reply to Manuel Lemos as well, we were told to use mail() and not attempt
        to talk directly to sendmail (or I think qmail is what they use).

        The mailing list is not terribly long, about 700 names that are all BCC'd,
        and similar scripts on other hosts handle easily two thousand names.

        Pierre
        --
        Pierre Jelenc | H o m e O f f i c e R e c o r d s
        | * Ethan Lipton * Marwood * The Cucumbers *
        T h e G i g o m e t e r | * Switchblade Kittens * Pawnshop *
        www.thegigometer.com | www.homeofficerecords.com

        Comment

        • Tim Van Wassenhove

          #5
          Re: mail() error handling

          On 2003-12-03, Pierre Jelenc <rcpj@panix.com > wrote:[color=blue]
          > The mailing list is not terribly long, about 700 names that are all BCC'd,
          > and similar scripts on other hosts handle easily two thousand names.[/color]

          Most ISPs don't accept mails with +500 bcc addresses.

          Without access to /var/log/mail.(log|warn| error) it is hard to tell what
          is going wrong.

          --
          verum ipsum factum

          Comment

          • Pierre Jelenc

            #6
            Re: mail() error handling

            Tim Van Wassenhove <euki@pi.be> writes:[color=blue]
            > On 2003-12-03, Pierre Jelenc <rcpj@panix.com > wrote:[color=green]
            > > The mailing list is not terribly long, about 700 names that are all BCC'd,
            > > and similar scripts on other hosts handle easily two thousand names.[/color]
            >
            > Most ISPs don't accept mails with +500 bcc addresses.[/color]

            This one does, it is actually a music-related company that offers cheap
            web sites for poor musicians, and it does not put limits on the number of
            addressees; each musician is known personally by the owners.
            [color=blue]
            > Without access to /var/log/mail.(log|warn| error) it is hard to tell what
            > is going wrong.[/color]

            OK, I'll try to have them look at it and tell me if they see something.

            Thanks,

            Pierre
            --
            Pierre Jelenc | H o m e O f f i c e R e c o r d s
            | * Ethan Lipton * Marwood * The Cucumbers *
            T h e G i g o m e t e r | * Switchblade Kittens * Pawnshop *
            www.thegigometer.com | www.homeofficerecords.com

            Comment

            • Manuel Lemos

              #7
              Re: mail() error handling

              Hello,

              On 12/03/2003 09:06 PM, Pierre Jelenc wrote:[color=blue][color=green][color=darkred]
              >>>I use mail() for a musician's mailing list script that suddenly started
              >>>having problems after many months of working flawlessly. The code fragment
              >>>is:[/color]
              >>
              >>before the if put in this
              >>echo "TO: $To SUBJECT: $Subject";
              >>
              >>If it outputs "TO: SUBJECT: " then i think you're php version has
              >>changed, and has register_global s=off now.
              >>
              >>[color=darkred]
              >>>if (mail($To,$Subj ect,$Body,$Head ers,$Param))[/color][/color]
              >
              >
              > No, no problem there. In further tests we found that some of the mail does
              > go through sometimes, but in unpredictable manner. Unfortunately I don't
              > have access to the machine's configuration, it is a shared machine and to
              > reply to Manuel Lemos as well, we were told to use mail() and not attempt
              > to talk directly to sendmail (or I think qmail is what they use).[/color]

              I do not know why you were told to do that because internally that is
              exactly what the mail() function implementation does, ie, either
              communicate directlty to the sendmail or qmail programs.

              --

              Regards,
              Manuel Lemos

              Free ready to use OOP components written in PHP
              Free PHP Classes and Objects 2025 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


              Comment

              • Pierre Jelenc

                #8
                Re: mail() error handling

                Manuel Lemos <mlemos@acm.org > writes:[color=blue]
                >
                > I do not know why you were told to do that because internally that is
                > exactly what the mail() function implementation does, ie, either
                > communicate directlty to the sendmail or qmail programs.[/color]

                I know, but this is a situation with people doing favors for other people
                on systems that are working OK but without full-time tech staff, and once
                they have something working (Ah! So they thought....) they don't want
                anyone going beyond the fence.

                Inspection of the logs shows what happened: Apparently, while going
                through its BCC list, qmail encountered a non-responsive server. Instead
                of skipping the problematic address and dealing with the others, it kept
                retrying, and timed out.

                What I don't understand is why qmail did not return "success" to mail()
                once it had received all the data, *then* tried to deliver the mail. I
                assume it's something that can be configured somewhere, as well as the odd
                behavior of not skipping an address that is giving trouble, but it's out
                of my reach.

                Pierre
                --
                Pierre Jelenc | H o m e O f f i c e R e c o r d s
                | * Ethan Lipton * Marwood * The Cucumbers *
                T h e G i g o m e t e r | * Switchblade Kittens * Pawnshop *
                www.thegigometer.com | www.homeofficerecords.com

                Comment

                • Manuel Lemos

                  #9
                  Re: mail() error handling

                  Hello,

                  On 12/06/2003 05:18 PM, Pierre Jelenc wrote:[color=blue][color=green]
                  >>I do not know why you were told to do that because internally that is
                  >>exactly what the mail() function implementation does, ie, either
                  >>communicate directlty to the sendmail or qmail programs.[/color]
                  >
                  >
                  > I know, but this is a situation with people doing favors for other people
                  > on systems that are working OK but without full-time tech staff, and once
                  > they have something working (Ah! So they thought....) they don't want
                  > anyone going beyond the fence.[/color]

                  I think you are not understanding what is communicating directly with
                  sendmail or qmail. You do not have to change anything in your server. It
                  is just executing those programs like the mail() function does. I think
                  you are just fearing the unknown.

                  [color=blue]
                  > Inspection of the logs shows what happened: Apparently, while going
                  > through its BCC list, qmail encountered a non-responsive server. Instead
                  > of skipping the problematic address and dealing with the others, it kept
                  > retrying, and timed out.[/color]

                  qmail does not do that. I think you are confused. Once you queue a
                  message with many Bcc: recipients, it will try to deliver the message to
                  many of them simultaneously upto to a limit of simultaneous deliveries.

                  All messages sent to addresses with delivery problems will make the
                  message stay in the queue for a while but that does not stop deliveries
                  of the same message or other message to other addresses.


                  [color=blue]
                  > What I don't understand is why qmail did not return "success" to mail()
                  > once it had received all the data, *then* tried to deliver the mail. I
                  > assume it's something that can be configured somewhere, as well as the odd
                  > behavior of not skipping an address that is giving trouble, but it's out
                  > of my reach.[/color]

                  qmail does not try to deliver messages immediately. You just queue the
                  message and it will try to delivery whenever it is possible. So, it
                  should always return success unless you have formatting problems that
                  make the qmail program fail and not queue any message at all.

                  --

                  Regards,
                  Manuel Lemos

                  Free ready to use OOP components written in PHP
                  Free PHP Classes and Objects 2025 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


                  Comment

                  Working...