require_once($_SERVER['DOCUMENT_ROOT'] . '/admin/cms/config.php');
error_reporting(E_ALL & ~E_NOTICE);
//Retrieve form data.
//GET - user submitted data using AJAX
//POST - in case user does not support javascript, we'll use POST instead
if(isset($_POST['nome']) && isset($_POST['email'])){
$name = ($_GET['nome']) ? $_GET['nome'] : $_POST['nome'];
$email = ($_GET['email']) ?$_GET['email'] : $_POST['email'];
$assunto = ($_GET['assunto']) ?$_GET['assunto'] : $_POST['assunto'];
$telefone = ($_GET['telefone']) ?$_GET['telefone'] : $_POST['telefone'];
$comment = ($_GET['mensagem']) ?$_GET['mensagem'] : $_POST['mensagem'];
$marketing = (isset($_POST['marketing']))?'Sim':'Não';
require_once($_SERVER['DOCUMENT_ROOT'] . "/admin/cms/config.php");
//Simple mail function with HTML header
function sendmail($to, $subject, $message, $from) {
global $NOMESITE,$EMAIL, $name;
require_once($_SERVER['DOCUMENT_ROOT'] . "/admin/email_smtp/mail_functions.php");
if(function_exists('mailSMTP')){
$toData = array(
'email' => $to,
'name' => $NOMESITE,
);
$fromData = array(
'email' => $from,
'name' => $name,
);
return mailSMTP($toData, $fromData, $subject, $message, $template);
}
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=utf-8" . "\r\n";
$headers .= 'From: '.$NOMESITE.'<'. $EMAIL . ">\r\n";
$headers .= 'Reply-To: '. $from . "\r\n";
$result = mail($to,$subject,$message,$headers);
if ($result) return true;
else return false;
}
//flag to indicate which method it uses. If POST set it to 1
if($name != '' && $email != ''){
if ($_POST) $post=1;
//recipient - replace your email here
require_once('admin/cms/config.php');
if(isset($EMAIL)) $to = $EMAIL;
else die('E-mail não configurado');
//sender - from the form
$from = $email;
//subject and the html message
$subject = 'Mensagem do Site: ' . $name;
$message = 'Nome: ' . $name . '
';
if(isset($assunto) && $assunto != '') $message .= "Telefone: $assunto
";
$message .= '
E-mail: ' . $email . '
Telefone: ' . $telefone . '
Mensagem: ' . nl2br($comment) . '
Marketing: ' . $marketing . '
';
$result = sendmail($to, $subject, $message, $from);
if ($result){
header('Location: ' . $WEB_URL . '/pt/?formEnviado=contacto&email='.$email.'');
}
else{
header('Location: ' . $WEB_URL . '/pt/?formEnviado=erro&email='.$email.'');
}
die();
}
}
?>