For testing purposes, let’s say input.PHP looks like this
<?php
{
$TO = "joe@net.net";
$FROM = "bob@net.net";
$SUB = "Yadda";
$BODY = "This is a test";
exec("/usr/bin/php /xxx.yyy.net/TESTS/sendit.PHP $TO $SUB $BODY $FROM > /dev/null &");
echo "DONE";
}
?>
And the sendit.PHP which is called by exec() looks like this
<?php
$to = $argv[1];
$subject = $argv[2];
$message = $argv[3];
$headers = 'From: '.$argv[4]. "\r\n" .
'Reply-To: '.$argv[4]. "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
When I open input.PHP in my browser, I get the echo DONE message, but the test email is not sent. What’s wrong with my code? Thank You.
Without error information, I’m not sure if this is the entire problem, but I’d start with this:
Arguments as read by
$argvare space-delimited. The following code:is executing as follows in your example:
That makes
$argv[3] == 'This'and$argv[4] == 'is'.