Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bad header=No recipient addresses found 1

Status
Not open for further replies.

Tama

MIS
Jun 6, 2001
121
NZ
I've recently moved servers and now a piece of PHP script is no longer working properly.

I pulls a bunch of e-mail addresses from a MySQL database and then sends them all a "group" e-mail. Except it only sends the e-mails to some (almost all) of the e-mail address and then comes up with this screen:
Code:
500 Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, admin@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.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request. [/quote]

Looking in the web error logs brings up this message:
[code]"malformed header from script. Bad header=No recipient addresses found"

I've checked the e-mail addresses back and forth (in this instance there's 65) and I can't see any which are the wrong format.

Here is the script:
Code:
$to = $email; <=$email directly from MySQL database
	$mailheaders = "From: $sender_name <$sender_email>\n";
	$mailheaders .= "Reply-To: $sender_email\n\n";
	mail($to, $subject, $msg, $mailheaders);

Any ideas on what's going wrong?

Cheers
Tama

I do my sums on fingers and thumbs.
 
It's an Apache/Linux box and PHP is running as "PHP Hypertext Preprocessor for Apache"

Is that the info you were after?

Cheers
Tama


I do my sums on fingers and thumbs.
 
No really.

PHP can run as a standalone interpreter which Apache invokes as a CGI. PHP can also run as an Apache module.

For the most part, running PHP either way does not matter. However, if you're running PHP as a CGI, you need to be more careful about sending necessary headers.

It looks to me like your script attempts to fetch the addresses, doesn't find any, and outputs an error. If PHP is running as a CGI, if the error output does not also output HTTP headers, you can get that error.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
The script definitely finds e-mail addresses and sends e-mails to them - it just doesn't send e-mails to everyone. It's a very hard thing to test without spamming the users with e-mail messages say "Just testing - ignore"

What would be the best way for me to work out how PHP is running on my server? I've got SSH access.

Cheers
Tama

I do my sums on fingers and thumbs.
 
OK - found it out:

PHP runs in CGI-BIN mode on my new server, and ran in Apache module mode on my old server.

I do my sums on fingers and thumbs.
 
That's related to your problem. If you're running PHP as a web-server module, you don't have to worry about the "Content-Type:" and other HTTP headers. If you're running PHP as a CGI, however, you do. At least on Unix-like OSes -- I believe the Win32 version automatically outputs headers when run.

The problem is that somewhere in your code, you're outputting the error message "No recipient addresses found", but are not also outputting at least a "Content-Type:" header.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
A gotcha - so in my send function I need to send a Content-Type Header

I do my sums on fingers and thumbs.
 
You need to set the header whereever it is you're sending that error message.

Or just send the header at the beginning of the script.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
This is in the script -
Code:
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";

But do I need to make this into a Header command like this one:

Code:
header("Cache-Control: no-store, no-cache, must-revalidate");

What's the correct syntax? Should I remove the HTML DOCTYPE?

I do my sums on fingers and thumbs.
 
Yikes! I put "header('Location: text/html');" in and got this error:
Code:
Not Found
The requested URL /text/html was not found on this server.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request. 

--------------------------------------------------------------------------------
Apache/1.3.27 Server at [URL unfurl="true"]www.vorb.org.nz[/URL] Port 80


I do my sums on fingers and thumbs.
 
Shouldn't I be using:
Code:
header('Content-type: text/html');


I do my sums on fingers and thumbs.
 
[Bad words]

Yeah, Tama, you're right. If I'd actually type what I mean, you'd be a lot better off.

Did:

header ("[red]Content-type[/red]: text/html");

make a difference?

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Heh heh - I should have stopped and thought on that one too.

OK - put the content header thing in and it's still producing this page when I try and send e-mails:
Code:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, admin@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.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request. 

--------------------------------------------------------------------------------
Apache/1.3.27 Server at [URL unfurl="true"]www.vorb.org.nz[/URL] Port 80

I'm going to try and work out a way to test this without e-mailing my users all the time.

I do my sums on fingers and thumbs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top