PHP变量没有显示在电子邮件中?

In the following code the variable $filedownload should be a link. It wont show when called outside of folder singleuse. When i do a similar script inside singleuse folder and change remove folder from include code, then it displays. I guess it might be todo with the include call? I would like to call the variable from outside the folder.

I tested the variable and it has a value. its just not showing up on the email.

<?php
/**
 *  This file creates the single use download link
 *  The query string should be the password (which is set in variables.php)
 *  If the password fails, then 404 is rendered
 *
 *  Expects: generate.php?1234
 */
    include("variables.php");

    // Grab the query string as a password
    $password = '1234';
    
    /*
     *  Verify the admin password (in variables.php)
     */ 
    if($password == ADMIN_PASSWORD) {
        // Create a new key
        $new = uniqid('key',TRUE);
        
        /*
         *  Create a protected directory to store keys in
         */
        if(!is_dir('keys')) {
            mkdir('keys');
            $file = fopen('keys/.htaccess','w');
            fwrite($file,"Order allow,deny
Deny from all");
            fclose($file);
        }
        
        /*
         *  Write the key key to the keys list
         */
        $file = fopen('keys/keys','a');
        fwrite($file,"{$new}
");
        fclose($file);
?>

<html>
    <head>
        <title>Download created</title>
        <style>
            nl { 
                font-family: monospace 
            }
        </style>
    </head>
    <body>
        <h1>Payment Success</h1>
        <?php 
            $filedownload = "http://" . $_SERVER['HTTP_HOST'] . DOWNLOAD_PATH . "?" . $new; 
        ?>
    </body>
</html>

<?php
    } else {
        /*
         *  Someone stumbled upon this link with the wrong password
         *  Fake a 404 so it does not look like this is a correct path
         */
        header("HTTP/1.0 404 Not Found");
    }
?>

include('/singleuse/generate.php');

$mail_From = "From: me@mybiz.com";
$mail_To = "savisaar2@gmail.com";
$mail_Subject = "VERIFIED IPN";
$mail_Body = "Hello there, thank you for purchasing from us. 
Please go to: " . $filedownload;

mail($mail_To, $mail_Subject, "

" . $mail_Body, $mail_From);
</div>

In a last effort i decided i would try to use a different php script for email, and it worked!

if ($payment_status == 'Completed') {
                            include('singleuse/generate.php');
                            
                            $to      = 'savisaar2@gmail.com';
                            $subject = 'Transation Completed [Ref #' . $txn_id . ']';
                            $message = 'Thank you ' . $payer_email . '! Your payment status is: ' . $payment_status . ', your order number is #' . $txn_id . '. Please follow this link to get your download: ' . $filedownload;
                            $headers = 'From: webmaster@dev4you.hints.me' . "
" .
                                'Reply-To: webmaster@dev4you.hints.me' . "
" .
                                'X-Mailer: PHP/' . phpversion();

                            mail($to, $subject, $message, $headers);

</div>