Hello!

For about two or three weeks now, I've had a cron job that runs every 5 minutes as part of an email subscription system I set up for my church. Yesterday something changed with our hosting server (it's shared hosting with Hostmonster) and now I'm getting an email every time the cron job runs because headers like these are being outputted:

X-Powered-By: PHP/5.2.13
P3P: CP="NOI NID ADMa OUR IND UNI COM NAV"
Cache-Control: private, must-revalidate
Set-Cookie: SN4b2c59593456c=4ql5n8rl157cj8tmb7o67bjh95; path=/
Set-Cookie: SN4b2c59593456c=4ql5n8rl157cj8tmb7o67bjh95; path=/
Content-type: text/html

I did some Googling and read that I should set "expose_php = Off" in my php.ini, but I did so and it didn't change anything. I used phpinfo() to check, and the setting is definitely being read as "Off", so there are no issues with my php.ini file.

I might submit a support ticket with Hostmonster, but they haven't been too helpful lately. What else can I do to get rid of the headers so I stop getting the status emails from the cron job? Also, I do want to get the emails when something goes wrong, so I can't just disable the emails for the cron job.

Thanks much!

Recommended Answers

All 2 Replies

In PHP ob_clean() is useful for flushing output headers, though I suspect that in this context they aren't really headers for PHP at all, but in PHP's context text that is passed as headers to the email service.

Are you able to provide any or all of the code for the cron script?

And is what you pasted there being sent to you via email, or is it being dumped somewhere into a log file? If it is being sent as an email, does all that text appear in the message's body, or do you need to view the message headers to see it?

All of the text in that quote shows up in the body of a plain-text email I get when the cron job runs.

My script uses MODx in API mode (modxcms.com if you haven't heard of it), and I realized that some of the headers are from that).

I read somewhere that using "-q" as an argument for my cron job command will silence any headers, and it seems to work. Now I'm getting an error from something else entirely that I'll have to work out, but for now running "php5 -q /path/to/script.php" seems to fix the problem with the headers being sent in the body of the email.

I'm pretty sure that MODx uses output buffering, so I'm not actually quite sure what might be going on here, but the strangest thing about it is that this just started a couple days ago without me making any changes to the script. For about two weeks I didn't get any emails with the headers. It just started all of a sudden, and my best guess is that Hostmonster changed/upgraded something on their servers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.