mail function generates 500 internal server error

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

    mail function generates 500 internal server error

    Hey,

    I had a hard disc problem last week on my server. I replaced the disc and
    copied al the files to the new hard disc, everything works fine again except
    some php scripts that are using the mail() function. When executing these
    scripts I get this error:
    "500 Internal Server Error
    The server encountered an internal error or misconfiguratio n and was unable
    to complete your request.

    Please contact the server administrator, webmaster@mydom ain.com and inform
    them of the time the error occurred, and anything you might have done that
    may have caused the error.

    More information about this error may be available in the server error log."


    In my logs I find this:malformed header from script. Bad
    header=/home/mydomain/dead.letter...: php-script

    Does somebody know what the problem could be?

    grt,

    Lieven


  • Gordon Burditt

    #2
    Re: mail function generates 500 internal server error

    >I had a hard disc problem last week on my server. I replaced the disc and[color=blue]
    >copied al the files to the new hard disc, everything works fine again except
    >some php scripts that are using the mail() function. When executing these
    >scripts I get this error:
    >"500 Internal Server Error
    >The server encountered an internal error or misconfiguratio n and was unable
    >to complete your request.
    >
    >Please contact the server administrator, webmaster@mydom ain.com and inform
    >them of the time the error occurred, and anything you might have done that
    >may have caused the error.
    >
    >More information about this error may be available in the server error log."
    >
    >
    >In my logs I find this:malformed header from script. Bad
    >header=/home/mydomain/dead.letter...: php-script[/color]

    The program invoked by the mail() function (often sendmail) is generating
    an error message, which is messing up your output since the web server
    thinks it is supposed to be a CGI header, but it isn't.

    Temporary workaround: output some text
    (e.g. <html><head><ti tle>This is a title</title></head><body>\n")
    *before* calling the mail function. You will see the error message
    text in the output from your page. Then figure out what it means.
    *SOMETHING* is wrong with the mail and it's saving it in a dead.letter
    file because it can't deliver it.
    [color=blue]
    >Does somebody know what the problem could be?[/color]

    Gordon L. Burditt

    Comment

    • Lieven

      #3
      Re: mail function generates 500 internal server error

      [color=blue]
      > Temporary workaround: output some text
      > (e.g. <html><head><ti tle>This is a title</title></head><body>\n")
      > *before* calling the mail function. You will see the error message
      > text in the output from your page. Then figure out what it means.
      > *SOMETHING* is wrong with the mail and it's saving it in a dead.letter
      > file because it can't deliver it.
      >[/color]
      I have tried this, but I'm still receiving this error. The online line I
      have in my php file is the line with the mail function.

      grt,

      Lieven


      Comment

      • Gordon Burditt

        #4
        Re: mail function generates 500 internal server error

        >> Temporary workaround: output some text[color=blue][color=green]
        >> (e.g. <html><head><ti tle>This is a title</title></head><body>\n")
        >> *before* calling the mail function. You will see the error message
        >> text in the output from your page. Then figure out what it means.
        >> *SOMETHING* is wrong with the mail and it's saving it in a dead.letter
        >> file because it can't deliver it.
        >>[/color]
        >I have tried this, but I'm still receiving this error. The online line I
        >have in my php file is the line with the mail function.[/color]

        When you see the error message, then click "view source" in your
        browser and paste the exact text of the error message and everything
        before it into a post.

        Gordon L. Burditt

        Comment

        • Lieven

          #5
          Re: mail function generates 500 internal server error

          >[color=blue]
          > When you see the error message, then click "view source" in your
          > browser and paste the exact text of the error message and everything
          > before it into a post.
          >[/color]
          This is the source code, I replaced my domain with "mydomain":
          <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
          <html><head>
          <title>500 Internal Server Error</title>
          </head><body>
          <h1>Internal Server Error</h1>
          <p>The server encountered an internal error or
          misconfiguratio n and was unable to complete
          your request.</p>
          <p>Please contact the server administrator,
          webmaster@mydom ain.be and inform them of the time the error occurred,
          and anything you might have done that may have
          caused the error.</p>
          <p>More information about this error may be available
          in the server error log.</p>
          <hr />
          <address>Apac he/2.0.50 (Fedora) Server at www.mydomain.be Port 80</address>
          </body></html>


          Comment

          • Jerry Stuckle

            #6
            Re: mail function generates 500 internal server error

            Lieven wrote:[color=blue][color=green]
            >>When you see the error message, then click "view source" in your
            >>browser and paste the exact text of the error message and everything
            >>before it into a post.
            >>[/color]
            >
            > This is the source code, I replaced my domain with "mydomain":
            > <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
            > <html><head>
            > <title>500 Internal Server Error</title>
            > </head><body>
            > <h1>Internal Server Error</h1>
            > <p>The server encountered an internal error or
            > misconfiguratio n and was unable to complete
            > your request.</p>
            > <p>Please contact the server administrator,
            > webmaster@mydom ain.be and inform them of the time the error occurred,
            > and anything you might have done that may have
            > caused the error.</p>
            > <p>More information about this error may be available
            > in the server error log.</p>
            > <hr />
            > <address>Apac he/2.0.50 (Fedora) Server at www.mydomain.be Port 80</address>
            > </body></html>
            >
            >[/color]

            Lieven,

            Looks like your mail() function is aborting for some reason. I suspect it may
            be taking one of the Apache processes with it.

            Anything in your Apache log?

            What MTA are you using, and is it running OK? I suspect this may be an in-house
            system (since you talked about disk failure). Can you send mail from your email
            program using the MTA on this system (not your ISP's)?


            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstucklex@attgl obal.net
            =============== ===

            Comment

            • Lieven

              #7
              Re: mail function generates 500 internal server error

              [color=blue]
              > Lieven,
              >
              > Looks like your mail() function is aborting for some reason. I suspect it
              > may be taking one of the Apache processes with it.
              >
              > Anything in your Apache log?
              >
              > What MTA are you using, and is it running OK? I suspect this may be an
              > in-house system (since you talked about disk failure). Can you send mail
              > from your email program using the MTA on this system (not your ISP's)?
              >
              >[/color]
              I'm using sendmail. This is a server that is running a hostingsapplica tion
              (ensim). It uses sendmail to send emails. My emailclient uses this server as
              outgoing server and this is working fine, I downloaded a php class that
              makes it possible to send mail by specifying a smtp sever and when I use
              'localhost' as smtp server this is working fine. If I lower the security
              level of a domain (this is a setting in my hostingsapplica tion), the mail
              functions works again, but it is really unsecure to do this for all my
              customers.
              The only error that I find was the one I mentioned earlier, the 'malformed
              header from script...'. Thnaks for your help!!

              grt,

              Lieven


              Comment

              • Jerry Stuckle

                #8
                Re: mail function generates 500 internal server error

                Lieven wrote:[color=blue][color=green]
                >>Lieven,
                >>
                >>Looks like your mail() function is aborting for some reason. I suspect it
                >>may be taking one of the Apache processes with it.
                >>
                >>Anything in your Apache log?
                >>
                >>What MTA are you using, and is it running OK? I suspect this may be an
                >>in-house system (since you talked about disk failure). Can you send mail
                >>from your email program using the MTA on this system (not your ISP's)?
                >>
                >>[/color]
                >
                > I'm using sendmail. This is a server that is running a hostingsapplica tion
                > (ensim). It uses sendmail to send emails. My emailclient uses this server as
                > outgoing server and this is working fine, I downloaded a php class that
                > makes it possible to send mail by specifying a smtp sever and when I use
                > 'localhost' as smtp server this is working fine. If I lower the security
                > level of a domain (this is a setting in my hostingsapplica tion), the mail
                > functions works again, but it is really unsecure to do this for all my
                > customers.
                > The only error that I find was the one I mentioned earlier, the 'malformed
                > header from script...'. Thnaks for your help!!
                >
                > grt,
                >
                > Lieven
                >
                >[/color]

                Lieven,

                Did you try asking the authors of the PHP class? Not knowing what it does (or
                even which class it is) makes it impossible to tell what's going on.

                Does a simple mail() command work? That would be the place to start if you're
                asking in this group.


                --
                =============== ===
                Remove the "x" from my email address
                Jerry Stuckle
                JDS Computer Training Corp.
                jstucklex@attgl obal.net
                =============== ===

                Comment

                • Lieven

                  #9
                  Re: mail function generates 500 internal server error

                  [color=blue]
                  >
                  > Lieven,
                  >
                  > Did you try asking the authors of the PHP class? Not knowing what it does
                  > (or even which class it is) makes it impossible to tell what's going on.[/color]
                  This script is just the normal phpmailer
                  (http://phpmailer.sourceforge.net/), there you can specify that you want to
                  use smtp like this:
                  $mailman = new PHPMailer();

                  $mailman->IsSMTP();

                  Using this tool, sending mails from our php scripts works, but it is
                  impossible to ask all our customers to change their php scripts.[color=blue]
                  >
                  > Does a simple mail() command work? That would be the place to start if
                  > you're asking in this group.[/color]

                  No, that is the whole problem. The mail function doesn't work anymore. After
                  a hard disk crash I copied the whole corrupt hard disk to a new disk,
                  everything else is working perfectly afterworths except php scripts that are
                  using the mail() function are getting the internal server error. I didn't
                  change anything to my configuration files or didn't update any application
                  on the server. Only raisonable explenation I have is that their must be some
                  kind of file corrupt after copying it to the new disk.

                  grt,

                  Lieven[color=blue]
                  >
                  >
                  > --
                  > =============== ===
                  > Remove the "x" from my email address
                  > Jerry Stuckle
                  > JDS Computer Training Corp.
                  > jstucklex@attgl obal.net
                  > =============== ===[/color]


                  Comment

                  • Rik

                    #10
                    Re: mail function generates 500 internal server error

                    Lieven wrote:[color=blue]
                    > No, that is the whole problem. The mail function doesn't work
                    > anymore. After a hard disk crash I copied the whole corrupt hard
                    > disk to a new disk, everything else is working perfectly afterworths
                    > except php scripts that are using the mail() function are getting the
                    > internal server error. I didn't change anything to my configuration
                    > files or didn't update any application on the server. Only raisonable
                    > explenation I have is that their must be some kind of file corrupt
                    > after copying it to the new disk.[/color]

                    I'd say, allthough a terrible job, back up settings and files, and install
                    everything as new. Who knows what else has become corrupt, that you just
                    haven't found out? It could be a simple function that doesn't work, it could
                    you're having a major security risk somewhere.

                    Grtz,
                    --
                    Rik Wasmus


                    Comment

                    • Jerry Stuckle

                      #11
                      Re: mail function generates 500 internal server error

                      Lieven wrote:[color=blue][color=green]
                      >>Lieven,
                      >>
                      >>Did you try asking the authors of the PHP class? Not knowing what it does
                      >>(or even which class it is) makes it impossible to tell what's going on.[/color]
                      >
                      > This script is just the normal phpmailer
                      > (http://phpmailer.sourceforge.net/), there you can specify that you want to
                      > use smtp like this:
                      > $mailman = new PHPMailer();
                      >
                      > $mailman->IsSMTP();
                      >
                      > Using this tool, sending mails from our php scripts works, but it is
                      > impossible to ask all our customers to change their php scripts.
                      >[color=green]
                      >>Does a simple mail() command work? That would be the place to start if
                      >>you're asking in this group.[/color]
                      >
                      >
                      > No, that is the whole problem. The mail function doesn't work anymore. After
                      > a hard disk crash I copied the whole corrupt hard disk to a new disk,
                      > everything else is working perfectly afterworths except php scripts that are
                      > using the mail() function are getting the internal server error. I didn't
                      > change anything to my configuration files or didn't update any application
                      > on the server. Only raisonable explenation I have is that their must be some
                      > kind of file corrupt after copying it to the new disk.
                      >
                      > grt,
                      >
                      > Lieven
                      >[color=green]
                      >>
                      >>--
                      >>============= =====
                      >>Remove the "x" from my email address
                      >>Jerry Stuckle
                      >>JDS Computer Training Corp.
                      >>jstucklex@att global.net
                      >>============= =====[/color]
                      >
                      >
                      >[/color]

                      Well, it's always possible a file got corrupted. Especially since you copied
                      files from a corrupt hard disk.

                      At this point I agree with Rik - you need to reinstall at least sendmail, php
                      and apache for a start. You should be able to keep your configuration files
                      (after ensuring they aren't corrupt), but get the rest of the files installed
                      with fresh copies.

                      Otherwise you may be spending days trying to find this bug - and even when you
                      find it, you wouldn't know if you might have another (more serious) bug.


                      --
                      =============== ===
                      Remove the "x" from my email address
                      Jerry Stuckle
                      JDS Computer Training Corp.
                      jstucklex@attgl obal.net
                      =============== ===

                      Comment

                      • Lieven

                        #12
                        Re: mail function generates 500 internal server error

                        [color=blue][color=green]
                        >>
                        >>
                        >>[/color]
                        >
                        > Well, it's always possible a file got corrupted. Especially since you
                        > copied files from a corrupt hard disk.
                        >
                        > At this point I agree with Rik - you need to reinstall at least sendmail,
                        > php and apache for a start. You should be able to keep your configuration
                        > files (after ensuring they aren't corrupt), but get the rest of the files
                        > installed with fresh copies.
                        >
                        > Otherwise you may be spending days trying to find this bug - and even when
                        > you find it, you wouldn't know if you might have another (more serious)
                        > bug.
                        >
                        >[/color]
                        Ok I think this will be indeed the right solution. I will reinstalled it and
                        I hope it will be fixed afterwards. Thanks for the support!!

                        grt,

                        Lieven


                        Comment

                        Working...