<?php

function mailOut($to, $from, $from_name, $subject, $body)
{
	//echo "entered";


	require("class.phpmailer.php");

		//echo "entered2";
	
	$mail = new PHPMailer();

	$mail->IsSMTP(true);                                      // set mailer to use SMTP
	$mail->Host = "smtp.gmail.com";  // specify main and backup server
	$mail->SMTPAuth = true;     // turn on SMTP authentication
	$mail->Username = "realcompemail@gmail.com";  // SMTP username
    $mail->Password = "BrentAnos7282!!"; // SMTP password
	$mail->SMTPSecure = "ssl"; // secure transfer enabled REQUIRED for GMail
	$mail->SMTPDebug = 1;
	$mail->Port = 465;


	$mail->From = $from; //
	$mail->FromName = $from_name; //
	
	 
	$pieces = explode(";", $to);
	
	foreach ($pieces as &$value) 
	{
		if (strlen($value) != 0)
			$mail->AddAddress($value, $value);
	}
	
	
	//$mail->AddAddress($to, $to); // this should be the user's email address
	
	
	//$mail->AddBCC("jocc@hotmail.com"); // this should be the office email address

	$mail->WordWrap = 100;                                 // set word wrap to 50 characters
	//$mail->AddAttachment("/var/tmp/file.tar.gz");         // add attachments
	//$mail->AddAttachment("/tmp/image.jpg", "new.jpg");    // optional name
	$mail->IsHTML(true);                                  // set email format to HTML

	$mail->Subject = $subject; //"Here is the subject";
	$mail->isHTML(true);
	$mail->Body    = $body; //"This is the HTML message body <b>in bold!</b>";
	//$mail->AltBody = "This is the body in plain text for non-HTML mail clients";

		//echo "entered3";
	
	if(!$mail->Send())
	{
		//echo "Message could not be sent. <p>";
		//echo "Mailer Error: " . $mail->ErrorInfo;
		//exit;
	}

	//echo "Message has been sent";

}

Function make()
{
	$ret =  "<html>".
			"<body>" . 
			"<span font=\"Arial\" color=\"gray\">" .
			"<b>Your Name (Authorised Representative for company):</b> " .  mysql_escape_string($_POST['f1']) . "<br/>" .
			"<b>Your Contact Number:</b> " . mysql_escape_string($_POST['f2']) . "<br/>" .
			"<b>Your Email:</b> " . mysql_escape_string($_POST['f3']) . "<br/>" .
			"<b>Company Name:</b> " .  mysql_escape_string($_POST['f4']) . "<br/>" .
			"<b>Company Address:</b> " . mysql_escape_string($_POST['f5']) . "<br/>" .
			"<b>Company ABN (ABN is an eligibility requirement):</b> " . mysql_escape_string($_POST['f6']) . "<br/>" .
			"<b>What is the reason for you contacting us about an Energy Efficiency Upgrade?:</b> " .  mysql_escape_string($_POST['f7']) . "<br/>" .
			"<b>What type of upgrade are you looking to do?:</b> " . mysql_escape_string($_POST['f8']) . "<br/>" .
			"<b>How soon are you looking to do the nominated upgrade?:</b> " . mysql_escape_string($_POST['f9']) . "<br/>" .
			"<b>What is your budget to complete the nominated upgrade?:</b> " .  mysql_escape_string($_POST['f10']) . "<br/>" .
			"<b>Do you have a preferred contractor that you would like us to use for the upgrade?:</b> " . mysql_escape_string($_POST['f11']) . " ... Contractor Details:" . mysql_escape_string($_POST['f11b']) . " <br/>" .
			"<b>Do you have any equipment on site access equipment (Scissor lift/EWP) for works to be completed or will it need to be hired?:</b> " . mysql_escape_string($_POST['f12']) . "<br/>" .
			"<b>Are you the person who will complete the final sign off on the upgrade?:</b> " .  mysql_escape_string($_POST['f13']) . " ... Person Details:" . mysql_escape_string($_POST['f13b']) . " <br/>" .
			"</p>" .
			"</span>" .
			"</body>" .
			"</html>"; 
			
	return $ret;
	 
	
	
}

echo make();
 

mailOut("cameron@carbonblue.com.au", "Request Site Assessment", "Request Site Assessment", "Request Site Assessment", make());

header("Location: request-assessment.php?rt=1#ll");

?>
