<?php
// There are two possible settings for sending mail from your contact forms.
// First option is mail php function, which is easier to set up, but might not be delivered always or marked as spam (especialy when using low quality hosting providers)
// Second option is to use SMTP. This requires a bit more configuration, but it is much more reliable.
// To use SMTP change useSMTP to "true" and configure options under SMTP settings. If you chose first option, than you just need to set up your mail address and nothing else.

//EDIT SETTINGS HERE:
$useSMTP = false;
$yourmail = "energyfivem@gmail.com";
//SMTP settings
$smtpUsername ="your username goes here";
$smtpPassword ="your password goes here";
$smtpHost ="your SMTP server: (ie: smtp.gmail.com)";

//STOP editing (unless you know what you're doing)

$email = $_POST['email'];
$subject = $_POST['subject'] ;
$message = $_POST['message'];
$name = $_POST['name'];

if ($useSMTP!=true) {

	if(mail( $yourmail, $subject . " from ".$name ,$message)) { 
		echo "<p class='success'>Contact Mail Sent.</p>";
	} else { 
	    echo "<p class='error'>Problem in Sending Mail.</p>";
	}  

} else {

	require('./phpmailer/class.phpmailer.php');

	$mail = new PHPMailer();
	$mail->IsSMTP();
	$mail->SMTPDebug = 0;
	$mail->SMTPAuth = TRUE;
	$mail->SMTPSecure = "tls";
	$mail->Port     = 587;  
	$mail->Username = $smtpUsername;
	$mail->Password = $smtpPassword;
	$mail->Host     = $smtpHost;
	$mail->Mailer   = "smtp";
	$mail->SetFrom($email, $name);
	$mail->AddReplyTo($email, $name);
	$mail->AddAddress($yourmail);	
	$mail->Subject = $subject ;
	$mail->WordWrap   = 80;
	$mail->MsgHTML($message);

	$mail->IsHTML(true);

	if(!$mail->Send()) {
		echo "<p class='error'>Problem in Sending Mail.</p>";
	} else {
		echo "<p class='success'>Contact Mail Sent.</p>";
	}	
}

?>