Skip to content

Instantly share code, notes, and snippets.

@enapupe
Forked from anonymous/gist:4290179
Created December 15, 2012 01:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enapupe/4290183 to your computer and use it in GitHub Desktop.
Save enapupe/4290183 to your computer and use it in GitHub Desktop.
<?php
//error_reporting(0);
$validation = array(
'email' => 'Digite um e-mail!',
'nome' => "Digite seu nome!"
);
foreach($validation as $key => $message){
if (empty($_POST[$key])){
echo json_encode(array('message' => $message, 'status' => 'fail'));
exit;
}
}
$txt = "<b>Contato enviado pelo site</b><br><br>";
$txt .= "Nome: " . $_POST['nome'] . "<br>";
$txt .= "E-mail: " . $_POST['email'] . "<br>";
$txt .= "Telefone: " . $_POST['telefone'] . "<br>";
$txt .= "Check In: " . $_POST['checkin'] . "<br>";
$txt .= "Check Out: " . $_POST['checkout'] . "<br>";
$txt .= "Pessoas: " . $_POST['pessoas'] . "<br>";
$txt .= "Reserva: " . nl2br($_POST['reserva']) . "<br>";
$txt .= "<br /><br />IP: " . $_SERVER['REMOTE_ADDR'];
$txt .= "<br />Data&Hora: " . date('d/m/Y H:i');
$txt .= "<br /><br />UserAgent: " . $_SERVER['HTTP_USER_AGENT'];
$headers = "MIME-Version: 1.1\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\n";
$headers .= 'From: [Reserva via Site] <contato@soleildabrava.com.br>' . "\n";
$headers .= "Return-Path: [Reserva via Site] <contato@soleildabrava.com.br>\n";
$headers .= "Reply-To: ".$_POST['nome']." <".$_POST['email'].">\n";
if (mail("iacamigevaerd@gmail.com", "[Contato Site]", $txt, $headers)) {
echo json_encode(array('message' => "Mensagem enviada!", 'status' => 'okay'));
} else {
echo json_encode(array('message' => "Houve um problema no envio do e-mail.", 'status' => 'fail'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment