<?
require_once 'lib/phpmailer/class.phpmailer.php';
$mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch
try {
	$body = '';
	foreach($_POST AS $idx=>$val){
			$body .= '<b>'.$idx.' :</b>'.($idx == 'Message'?'<br>':'').' '.$val.'<br>';
	}
	$mail->CharSet = "UTF-8";
	$mail->IsHTML(true);
	$mail->AddReplyTo('tallinn@amrop.com');
	$mail->AddAddress('tallinn@amrop.com');
	$mail->SetFrom('tallinn@amrop.com');
	$mail->Subject = 'Amrop.ee Contact form';
	$mail->Body = $body;
	$mail->Send();
	echo "1";
} catch (phpmailerException $e) {
	echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
	echo $e->getMessage(); //Boring error messages from anything else!
}
?>