By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,558 Members | 1,533 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,558 IT Pros & Developers. It's quick & easy.

mail function generates 500 internal server error

P: n/a
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 misconfiguration and was unable
to complete your request.

Please contact the server administrator, we*******@mydomain.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
May 12 '06 #1
Share this Question
Share on Google+
11 Replies


P: n/a
>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 misconfiguration and was unable
to complete your request.

Please contact the server administrator, we*******@mydomain.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
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><title>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.
Does somebody know what the problem could be?


Gordon L. Burditt
May 12 '06 #2

P: n/a
Temporary workaround: output some text
(e.g. <html><head><title>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.

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
May 15 '06 #3

P: n/a
>> Temporary workaround: output some text
(e.g. <html><head><title>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.

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.


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
May 15 '06 #4

P: n/a
>
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.

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
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
we*******@mydomain.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>Apache/2.0.50 (Fedora) Server at www.mydomain.be Port 80</address>
</body></html>
May 15 '06 #5

P: n/a
Lieven wrote:
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.


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
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
we*******@mydomain.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>Apache/2.0.50 (Fedora) Server at www.mydomain.be Port 80</address>
</body></html>


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.
js*******@attglobal.net
==================
May 16 '06 #6

P: n/a
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)?

I'm using sendmail. This is a server that is running a hostingsapplication
(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 hostingsapplication), 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
May 16 '06 #7

P: n/a
Lieven wrote:
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)?


I'm using sendmail. This is a server that is running a hostingsapplication
(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 hostingsapplication), 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


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.
js*******@attglobal.net
==================
May 16 '06 #8

P: n/a

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. 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.
Does a simple mail() command work? That would be the place to start if
you're asking in this group.
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

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

May 16 '06 #9

P: n/a
Rik
Lieven wrote:
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.


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
May 16 '06 #10

P: n/a
Lieven wrote:
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.


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.
Does a simple mail() command work? That would be the place to start if
you're asking in this group.

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

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================



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.
js*******@attglobal.net
==================
May 16 '06 #11

P: n/a



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.

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
May 18 '06 #12

This discussion thread is closed

Replies have been disabled for this discussion.