<?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>Name of Person/Company making complaint:</b> " .  mysql_escape_string($_POST['f1']) . "<br/>" .
			"<b>Contact Number:</b> " . mysql_escape_string($_POST['f2']) . "<br/>" .
			"<b>Your Email:</b> " . mysql_escape_string($_POST['f3']) . "<br/>" .
			"<b>Location of premises:</b> " .  mysql_escape_string($_POST['f5']) . "<br/>" .
			"<b>Complaint:</b> " . mysql_escape_string($_POST['f6']) . "<br/>" .
			"<b>Date of Complaint:</b> " . mysql_escape_string($_POST['f7']) . "<br/>" .
	                "</span>" .
			"</body>" .
			"</html>"; 
			
	return $ret;
	 
	
	
}

echo make();
 

mailOut("cameron@carbonblue.com.au", "Complaint", "Complaint", "Complaint", make());

header("Location: complaints.php?rt=1#ll");

?>
