Make sure the file is in UNIX format.
PHP knows how to parse windows format text files, so the script will work when ran through Apache/PHP
However when the script is ran via the shell; the shell is trying to parse the firstline and it screws up.
I think it will be the case that the script will read the whole file as one long line, as it encounters no UNIX line breaks (\n\r), effectively it will pass
>-q\n<?php etc...
to PHP which will then ignore all the text after the \n so nothing happens!
or (depends on the ' -q' as the space after the /php will cause the above)
the shell will try to pipe the email to
>#!/usr/local/bin/php\n<?php etc...
rather than
>#!/usr/local/bin/php
and you will get an error.
either way it fails.
Some FTP clients will do file conversion automatically so some of you will not find this happening