PHP变量未显示在电子邮件中


PHP variable not showing in email?

在下面的代码中,变量$filedownload应该是一个链接。当在文件夹外调用时,它不会显示。当我在singleuse文件夹中执行类似的脚本并从include代码中更改remove文件夹时,它就会显示出来。我想可能是todo和include通话?我想从文件夹外部调用该变量。

我测试了这个变量,它有一个值。它只是没有出现在电子邮件中。

<?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'nDeny from all");
			fclose($file);
		}
		
		/*
		 *	Write the key key to the keys list
		 */
		$file = fopen('keys/keys','a');
		fwrite($file,"{$new}'n");
		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. 'nPlease go to: " . $filedownload;
mail($mail_To, $mail_Subject, "'n'n" . $mail_Body, $mail_From);

在最后一次尝试中,我决定尝试使用不同的php脚本来处理电子邮件,结果成功了!

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' . "'r'n" .
							    'Reply-To: webmaster@dev4you.hints.me' . "'r'n" .
							    'X-Mailer: PHP/' . phpversion();
							mail($to, $subject, $message, $headers);