<?PHP
	if (!defined("ALLSITES")) define ("ALLSITES","/var/www/sites/allsites");
	$allsites="/var/www/sites/allsites";
	include ("$allsites/.htemail.inc.php");
	
	$site="https://www.reloid.com/enrollments/cheapcerts3";

	if (!function_exists("email_HTML"))
	{
		function email_HTML($to,$from,$subject,$boundary,$HTMLpart,$plainpart)
		{
			$headers="From: $from";
			$headers.="\n";
			$headers.=email_MIME_alternative_header($boundary);
			$body="\nThis is a multipart MIME message.  If you see this, get a more modern email client.";
			if (strlen($plainpart)>0) $body.="\n".email_MIME_body_header_plain($boundary).$plainpart;
			if (strlen($HTMLpart)>0) $body.="\n".email_MIME_body_header_HTML($boundary).$HTMLpart;
			$body.="\n".email_MIME_body_header_end($boundary);
			#echo "We are sending<br><pre>$body</pre><br>to $to, from $from, about $subject.";
			return mail($to,$subject,$body,$headers);
			#return email_sign_and_encrypt($subject,$tocert,$fromcert,$key,$body,$headers);
		}
	}

	$URI="$site/getcert.php";
	$email=$_REQUEST["email"];
	$plpart="This is an email to help you verify your email address so that we can issue you a certificate.";
	$plpart.="  Please copy and paste this URI into your browser:\n$URI?email=$email";
	$msg="";
	#$msg.="<html><body>";
	$msg.="\n<form action=\"$URI\" method=post>";
	$msg.="\n<p>Please click the button below to get your certificate.</p>";
	$msg.="\n<input type=hidden name=email value=\"$email\">";
	$msg.="\n<input type=submit value=Gimme>";
	$msg.="\n</form>";
	$msg="<p>Please click <a href=$URI?email=$email>here</a> to get your certificate.</p>";
	#$msg.="\n</body></html>";

	if (email_HTML($email,"certifier@reloid.com","Validation for Certificate","Identity is the foundation of security.",$msg,$plpart))
	{
		echo "<html><head>";
		echo "</head><body>";
		echo "<p>We have sent you an email which you must open and click on the button there.";
		echo "</body></html>";
	}
	else
	{
		echo "<html><head>";
		echo "</head><body>";
		echo "<p>Sorry, we were unable to send you an email.  You lose.";
		echo "</body></html>";
	}
?>