我正在使用带有电子邮件确认的自定义页面模板。一切正常,除了当我单击电子邮件中的链接时,它给了我“找不到页面”。
PHP 脚本有什么问题?
这是片段:
ob_start();
$email= '';
if(isset($_POST['submit'])){
if(!($_POST['subscriptions']=="")){
$email= isset($_POST['subscriptions']) ? $_POST['subscriptions'] : '';
function encryptLink($stringValue){
$key = "12345";
$qryStr = "subscriptions=".$stringValue;
$query = base64_encode(urlencode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $qryStr, MCRYPT_MODE_CBC, md5(md5($key)))));
$link = 'www.example.com/testEnvironment/confirmation/'.$query;
return $link;
}
$string = $email;
$pagelink = encryptLink($string);
//Email Details
$mail_to = $email;
$from_mail = "dummyemail@example.com";
$from_name = "";
$reply_to = "";
$subject = "Confirmation";
$message_body =
'Hey,
<span style="overflow-wrap: break-word; word-wrap: break-word;">'.$pagelink.'</span>';
//Generate a boundary
$boundary = md5(uniqid(time()));
//Email Header
$header = "From: ".$from_mail." \r\n";
$header .= "Reply-To: ".$reply_to."\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed;\r\n";
$header .= " boundary=\"".$boundary."\"";
//Multipart wraps the Email Content
$message_body .= "\r\n\r\n";
$message_body .= "--".$boundary."\r\n";
$message_body .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
$message_body .= "Content-Transfer-Encoding: 7bit\r\n";
$message_body .= "\r\n";
$message_body .= "$message_body\r\n";
$message_body .= "--".$boundary."\r\n";
//Send email
if (mail($mail_to, $subject, $message_body, $header)){
echo "Sent";
} else {
echo "Error";
}
}
}
确认页面 PHP 代码段:
$key = "12345";
$queryString = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), urldecode(base64_decode($_SERVER['QUERY_STRING'])), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
parse_str($queryString);
if(!empty($stringValue)){
echo $stringValue;
} else{
exit("Invalid parameters passed");
}