Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Jeovane Carvalho

Erros na acentuação no envio das mensagens para o remetente

Recommended Posts

Olá pessoal há semanas estou tentando resolver um problema de codificação no php que esta fritando meu neurônios, vamos lá...

Criei um site em php roda na plataforma windows e criei um fomulário com auto resposta que esta neste link http://www.jcimoveisbrasil.com/pedido.php ele funciona perfeitamente no envios dos dados e os mesmos chega corretamente só que o problema, que no campo remetente do email por exemplo se o a pessoa se chamar Débora ele chega assim no remetente "Débora" e no campo assunto também chega desconfigurado, eu consegui codificar a auto resposta e chega perfeitamente, segue abaixo o código...

 

 

Esse é o index ...

 

 

<?php


// This will show in the browsers title bar and at the top of the form.
$websitename="FORMULÃRIO PARA PEDIDO DE IMÓVEL";
// Allowed file types. Please remember to keep the format of this array, add the file extensions you want
// WITHOUT the dot. Please also be aware that certain file types (such as exe) may contain malware.
$allowtypes=array("zip", "rar", "txt", "doc", "jpg", "png", "gif", "odt", "xml");

// What's your email address? Seperate email addresses with commas for multiple email addresses.
$myemail=" email@email.com";
// What priority should the script send the mail? 1 (Highest), 2 (High), 3 (Normal), 4 (Low), 5 (Lowest).
$priority="1";

// Should we allow visitors to attach files? How Many? 0 = Do not allow attachments,
// 1 = allow only 1 file to be attached, 2 = allow two files etc.
$allowattach="0";

// Maximum file size for attachments in KB NOT Bytes for simplicity. MAKE SURE your php.ini can handel it,
// post_max_size, upload_max_filesize, file_uploads, max_execution_time!
// 2048kb = 2MB, 1024kb = 1MB, 512kb = 1/2MB etc..
$max_file_size="2024";

// Maximum file size for all attachments combined in KB. MAKE SURE your php.ini can handel it,
// post_max_size, upload_max_filesize, file_uploads, max_execution_time!
// 2048kb = 2MB, 1024kb = 1MB, 512kb = 1/2MB etc..
$max_file_total="3048";

// Value for the Submit Button
$submitvalue="Enviar Dados";

// Value for the Reset Button
$resetvalue=" Limpar Dados";

// Default subject? This will be sent if the user does not type in a subject
$defaultsubject="Sem assunto";

// Because many requested it, this feature will add a drop down box for the user to select a array of
// subjects that you specify below.
// True = Use this feature, False = do not use this feature
$use_subject_drop=false;

// This is an array of the email subjects the user can pick from. Make sure you keep the format of
// this array or you will get errors.
// Look at <[url=http://novahq.net/forum/showthread.php?t=38718]http://novahq.net/forum/showthread.php?t=38718 [/url]> for examples on how to use this feature.
$subjects=array("Agendar visita", "Dúvidas", "Financiamento");

// This is an array of the email addresses for the array above. There must be an email FOR EACH
// array value specified above. You can have only 1 department if you want.
// YOU MUST HAVE THE SAME AMMOUNT OF $subjects and $emails or this WILL NOT work correctly!
// The emails also must be in order for what you specify above!
// Seperate email addresses by a comma to send an email to multiple addresses.
$emails=array("jcimoveisbrasil@hotmail.com", "dept_2@domain.com", "dept_3@domain.com");

// This is the message that is sent after the email has been sent. You can use html here.
// If you want to redirect users to another page on your website use this:
// <script type=\"text/javascript\">window.location=\"[url=/page.html%5C]http://www.YOUR_URL.com/page.html\ [/url]";</script>
$thanksmessage="Mensagem enviado com Sucesso ...Aguarde o nosso retorno. Obrigado.";

/*
//================================================================================
* ! ATTENTION !
//================================================================================
: Don't edit below this line.
*/

// Function to get the extension of the uploaded file.
function get_ext($key) {
$key=strtolower(substr(strrchr($key, "."), 1));
$key=str_replace("jpeg", "jpg", $key);
return $key;
}

// Function used to attach files to the message
function phattach($file, $name, $boundary) {

$fp=fopen($file, "r");
$str=fread($fp, filesize($file));
$str=chunk_split(base64_encode($str));
$message="--".$boundary."\n";
$message.="Content-Type: application/octet-stream; name=\"".$name."\"\n";
$message.="Content-disposition: attachment; filename=\"".$name."\"\n";
$message.="Content-Transfer-Encoding: base64\n";
$message.="\n";
$message.="$str\n";
$message.="\n";

return $message;
}

//Little bit of security from people forging headers. People are mean sometimes :(
function clean_msg($key) {
$key=str_replace("\r", "", $key);
$key=str_replace("\n", "", $key);
$find=array(
"/bcc\:/i",
"/Content\-Type\:/i",
"/Mime\-Type\:/i",
"/cc\:/i",
"/to\:/i"
);
$key=preg_replace($find, "", $key);
return $key;
}

// Initilize some variables
$error="";
$sent_mail=false;



// When the form is submitted
If($_POST['submit']==true) {
extract($_POST, EXTR_SKIP);

// Check the form for errors
If(trim($yourname)=="") {
$error.="Preencha o campo Nome!<br />";
} Elseif(!preg_match("/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/", $youremail)) {
$error.="Email Inválido.<br />";
}

If(trim($emailsubject)=="") {
$emailsubject=$defaultsubject;
}

If(trim($yourtelefone)=="") {
$error.="Preencha o campo Telefone!<br />";
}


If(trim($yourimovel)=="") {
$error.="Preencha o campo Tipo de Imóvel!<br />";
}
If(trim($yourdormitorios)=="") {
$error.="Preencha o campo Número de Dormitórios<br />";
}
If(trim($yourvagas)=="") {
$error.="Preencha o campo Número de Vagas!<br />";
}

If(trim($youracabamento)=="") {
$error.="Preencha o campo Preferência de Acabamento!<br />";
}

If(trim($yourescritura)=="") {
$error.="Preencha o campo Imóvel de Condomínio ou de Rua!<br />";
}

If(trim($youriptu)=="") {
$error.="Preencha o campo Localidade!<br />";
}

If(trim($yourfinanciado)=="") {
$error.="Preencha o campo Financiamento Bancário!<br />";
}

If(trim($yourlocalidade)=="") {
$error.="Preencha o campo Imóvel Residencial / Comercial!<br />";
}

If(trim($yourcidade)=="") {
$error.="Preencha o campo Compra ou Locação!<br />";
}

If(trim($yourvalor)=="") {
$error.="Preencha o campo Valor!<br/>";
}


If(trim($yoursite)=="") {
$error.="Preencha o campo Nosso site!<br />";
}



If(trim($yourmessage)=="") {
$error.="Preencha o campo Mensagem!<br />";
}

// Verify Attchment info
If($allowattach > 0) {

// Get the total size of all uploaded files
If((array_sum($_FILES['attachment']['size'])) > ($max_file_total*1024)) {

$error.="The max size allowed for all your files is ".$max_file_total."kb<br />";

} Else {

//Loop through each of the files
For($i=0; $i <= $allowattach-1; $i++) {

If($_FILES['attachment']['name'][$i]) {

//Check if the file type uploaded is a valid file type.
If(!in_array(get_ext($_FILES['attachment']['name'][$i]), $allowtypes)) {

$error.= "Invalid file type for your file: ".$_FILES['attachment']['name'][$i]."<br />";

//Check the size of each file
} Elseif(($_FILES['attachment']['size'][$i]) > ($max_file_size*1024)) {

$error.= "Your file: ".$_FILES['attachment']['name'][$i]." is to big.<br />";

} // If in_array

} // If Files

} // For

} // Else array_sum($_FILES['attachment']['size'])

} // If Allowattach

If($error) {

$display_message=$error;

} Else {

If($use_subject_drop AND is_array($subjects) AND is_array($emails)) {
$subject_count=count($subjects);
$email_count=count($emails);

If($subject_count==$email_count) {

$myemail=$emails[$emailsubject];
$emailsubject=$subjects[$emailsubject];

} // If $subject_count

} // If $use_subject_drop

$boundary=md5(uniqid(time()));

//Headers
$headers="Return-Path: <".clean_msg($youremail).">\n";
$headers.="From: ".clean_msg($yourname)." <".clean_msg($youremail).">\n";
$headers.="X-Mailer: PHP/".phpversion()."\n";
$headers.="X-Sender: ".$_SERVER['REMOTE_ADDR']."\n";
$headers.="X-Priority: ".$priority."\n";
$headers.="MIME-Version: 1.0\n";
$headers.="Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n";
$headers.="This is a multi-part message in MIME format.\n";

//Message
$message = "--".$boundary."\n";
$message.="Content-Type: text/html; charset=\"iso-8859-1\"\n";
$message.="Content-Transfer-Encoding: quoted-printable\n";
$message.="\n";

$message.= "<strong>Nome:</strong> $yourname<br />";
$message.="\n";
print ("$var \n");


$message.="\n";
$message.= "<strong>Email:</strong> $youremail<br />";
$message.="\n";
print ("$var \n");


$message.="\n";
$message.= "<strong>Telefone:</strong> $yourtelefone<br />";
$message.="\n";
print ("$var \n");
$message.= "<strong>Tipo de Imóvel:</strong> $yourimovel<br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Número de Dormitórios:</strong> $yourdormitorios<br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Número de Vagas:</strong> $yourvagas<br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Preferência de Acabamento (sim/não):</strong> $youracabamento<br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Forma de Pagamento (sim/não):</strong> $yourescritura<br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Localidade (sim/não):</strong> $youriptu<br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Financiamento Bancário(sim/não):</strong> $yourfinanciado<br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Localidade (Bairro):</strong> $yourlocalidade<br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Qual Banco:</strong> $yourcidade<br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Valor:</strong> $yourvalor<br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Como conheceu nosso site:</strong> $yoursite<br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Mensagem:</strong> $yourmessage<br />";
$message.="\n";
print ("$var \n");
//Add attachments to message
If($allowattach > 0) {

For($i=0; $i <= $allowattach-1; $i++) {

If($_FILES['attachment']['tmp_name'][$i]) {

$message.=phattach($_FILES['attachment']['tmp_name'][$i], $_FILES['attachment']['name'][$i], $boundary);

} //If $_FILES['attachment']['name'][$i]

} //For

} // If

// End the message
$message.="--".$boundary."--\n";

// Send the completed message
If(!mail($myemail, clean_msg($emailsubject), $message, $headers)) {

Exit("An error has occured, please report this to the website administrator.\n");

} Else {

$sent_mail=true;

}

} // Else

} // $_POST

/*
//================================================================================
* Start the form layout
//================================================================================
:- Use the html below to customize the form.
*/
?>
</div>
<title><?php echo $websitename; ?>CADASTRO DE IMÓVEL</title>
<script type="text/javascript">
function Checkit(theform){
if(theform.yourname.value=="")
{
alert('Preencha o campo nome!')
theform.yourname.focus()
return false;
}

if(theform.youremail.value == "" )
{
alert('Preencha o campo Email!')
theform.youremail.focus()
return false;
}

if(theform.youremail.value.indexOf('@')==-1 || theform.youremail.value.indexOf('.')==-1 ){
alert("EMAIL inválido digite novamente.");
theform.youremail.focus()
return false;
}

if(theform.yourtelefone.value == "" )
{
alert('Preencha o campo Telefone!')
theform.yourtelefone.focus()
return false;
}
if(theform.yourimovel.value == "" )
{
alert('Preencha o campo Tipo de Imóvel!')
theform.yourimovel.focus()
return false;
}

if(theform.yourdormitorios.value == "" )
{
alert('Preencha o campo Número de Dormitórios!')
theform.yourdormitorios.focus()
return false;
}

if(theform.yourvagas.value == "" )
{
alert('Preencha o campo Vagas!')
theform.yourvagas.focus()

return false;
}

if(theform.youracabamento.value == "" )

{
alert('Preencha o campo Preferência por Acabamento!')
theform.youracabamento.focus()
return false;
}

if(theform.yourescritura.value == "" )
{
alert('Preencha o campo Imóvel de Condomínio ou de Rua!')
theform.yourescritura.focus()
return false;

}
if(theform.youriptu.value == "" )
{
alert('Preencha o campo Localidade!')
theform.youriptu.focus()
return false;
}
if(theform.yourfinanciado.value == "" )
{
alert('Preencha o campo Financiamento Bancário!')
theform.yourfinanciado.focus()
return false;
}

if(theform.yourlocalidade.value == "" )
{
alert('Preencha o campo Localidade!')
theform.yourlocalidade.focus()
return false;
}

if(theform.yourcidade.value == "" )
{
alert('Preencha o campo Cidade!')
theform.yourcidade.focus()
return false;
}

if(theform.yourvalor.value == "" )
{
alert('Preencha o campo Valor!')
theform.yourvalor.focus()
return false;
}
if(theform.yoursite.value == "" )
{
alert('Preencha o campo como conheceu nosso Site!')
theform.yoursite.focus()
return false;
}
if(theform.emailsubject.value == "" )
{
alert('Preencha o campo Assunto!')
theform.emailsubject.focus()
return false;
}
if(theform.yourmessage.value == "" )
{
alert('Preencha o campo Mensagem!')
theform.yourmessage.focus()
return false;
}

if(error) {
alert('**O Formulário possuem erros:**\n\n' + error);
error="";
return false;
}
return true;
}
</script>
</head>

<?php If($display_message) {?>

<div align="center" class="error_message"><b><?php echo $display_message;?></b></div>
<br />
<?php }?>
<?php If($sent_mail!=true) {?>
<script type="text/javascript"> var RecaptchaOptions = { theme : 'white' }</script>
<form method="post" id="contactform" action="pedido2.php" enctype="multipart/form-data" name="phmailer" onsubmit="return Checkit(this);">
<table width="593" align="center" class="table">
<tr>
<td colspan="2" class="table_header"><?php echo $websitename;?></td>
</tr>
<?php If($allowattach > 0) {?>
<tr>
<td class="attach_info" colspan="2">
</td>
</tr>
<tr>
<td class="attach_info" colspan="2">
<center><b>PREENCHA OS DADOS DE SEU IMÓVEL ABAIXO PARA DAR INICIO AO NOSSO TRABALHO:</b></center>
</td>
</tr>
<tr>
<td class="attach_info" colspan="2">
</td>
</tr>
<?php }?>
<tr>
<td width="55%" class="table_body">     Seu Nome:</td>
<td width="45%" class="table_body"><input name="yourname" type="text" size="20" value="<?php echo stripslashes(utf8_encode($yourname));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Seu Email:</td>
<td width="45%" class="table_body"><input name="youremail" type="text" size="20" value="<?php stripslashes(htmlspecialchars($youremail));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Seu Telefone:</td>
<td width="45%" class="table_body"><input name="yourtelefone" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($yourtelefone));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Tipo de Imóvel:</td>
<td width="45%" class="table_body"><input name="yourimovel" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($yourimovel));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Número de Dormitórios:</td>
<td width="45%" class="table_body"><input name="yourdormitorios" type="text" size="20"value="<?php echo stripslashes(htmlspecialchars($yourdormitorios));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Número de Vagas:</td>
<td width="45%" class="table_body"><input name="yourvagas" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($yourvagas));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Preferência por Acabamento (s/n):</td>
<td width="45%" class="table_body"><input name="youracabamento" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($youracabamento));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Imóvel de Condomínio ou de Rua:</td>
<td width="45%" class="table_body"><input name="yourescritura" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($yourescritura));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Localidade:
</td>
<td width="45%" class="table_body"><input name="youriptu" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($youriptu));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Financiamento Bancário (s/n):</td>
<td width="45%" class="table_body"><input name="yourfinanciado" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($yourfinanciado));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Imóvel Residencial ou Comercial:</td>
<td width="45%" class="table_body"><input name="yourlocalidade" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($yourlocalidade));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Para Compra ou Locação:</td>
<td width="45%" class="table_body"><input name="yourcidade" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($yourcidade));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Valor:</td>
<td width="45%" class="table_body"><input name="yourvalor" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($yourvalor));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Como conheceu nosso Site:</td>
<td width="45%" class="table_body"><input name="yoursite" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($yoursite));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Assunto:</td>
<td width="45%" class="table_body">
<?php If($use_subject_drop AND is_array($subjects)) {?>
<select name="emailsubject" size="1">
<?php while(list($key,$val)=each($subjects)) {?>
<option value="<?php echo intval($key);?>"><?php echo htmlspecialchars(stripslashes($val));?></option>
<?php }?>
</select>
<?php } Else {?>
<input name="emailsubject" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($emailsubject));?>" /><span class="error_message">*</span>
<?php }?>
</td>
</tr>
<tr>
<td class="attach_info" colspan="2">
</td>
</tr>
<tr>
<td class="attach_info" colspan="2">
</td>
</tr>
<tr>
<td class="attach_info" colspan="2">
</td>
</tr>
<?php For($i=1;$i <= $allowattach; $i++) {?><tr>
<td width="55%" class="table_body">     Adicione Fotos</td>
<td width="45%" class="table_body"><input name="attachment[]" type="file" size="30" /></td>
</tr>
<?php }?>
<tr>
<td colspan="2" class="table_body">          
<div align="center">Preencha mais informações sobre o Imóvel<span class="error_message">*</span><br />
</div>
<div align="center">
<textarea name="yourmessage" rows="8" cols="60"><?php echo stripslashes(htmlspecialchars($yourmessage));?></textarea>
<table width="463" border="0">
<tr>
<td width="45"> </td>
<td width="361"><h8>
<div align="center">Digite aqui os caracteres abaixo</div>
</h8></td>
<td width="43"> </td>
</tr>
</table>
 
//INÍCIO CAPCTHA DO GOOGLE.
<?php
require_once('recaptchalib.php');
// Get a key from [url=https://www.google.com/recaptcha/admin/create]https://www.google.com/recaptcha/admin/create [/url]
$publickey = "      ";
$privatekey = "    ";
# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;
# was there a reCAPTCHA response?
if ($_POST["recaptcha_response_field"]) {
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

if ($resp->is_valid) {
echo "You got it!";
} else {
# set the error code so that we can display it
$error = $resp->error;
}
}
echo recaptcha_get_html($publickey, $error);
?>
 
//FIM CAPCTHA DO GOOGLE.

</div>
</td>
</tr>
<tr>
<td colspan="2" class="table_footer">
<tr>
<td class="attach_info" colspan="2" >
<table width="542" border="0">
<tr>
<td width="137"> </td>
<td width="182"><input type="submit" name="submit" value="<?php echo $submitvalue;?>" /></td>
<td width="17"><input type="hidden" name="submit2" value="true" /></td>
<td width="173"><input type="reset" value="<?php echo $resetvalue;?>" /></td>
<td width="11"> </td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</form>
<?php } Else {?>
<div align="center" class="thanks_message"><?php echo $thanksmessage;?>
<div align="center">
<br /><br />
<?php }
//Please leave this here.. It's very small and non-obtrusive. ?>
 
 
 
E ESTE É O ENVIA.PHP
 
 
//VERIFICADOR DO CAPCTHA DO GOOGLE.
 
<?php
ini_set( 'default_charset', 'utf-8');
?>

<?php
require_once('recaptchalib.php');
$privatekey = " ";  // coloque aqui a Private key
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
  if (!$resp->is_valid) {
   
// O que acontece quando o CAPTCHA for digitado incorretamente
echo "<script>alert('** Código incorreto, insira novamente **');</script>";
echo "<script language='javascript'>history.back()</script>";
} else {
echo "<script>alert('**  Mensagem enviada com Sucesso: A Jc Imóveis Brasil agradeçe  **');</script>";
echo "<script language='javascript'>history.back()</script>";
echo "<script>window.location = \"index.php\"</script>";
 
//FIM DO VERIFICADOR DO CAPCTHA DO GOOGLE.

/*


/*
//================================================================================
* ! ATENÇÃO
!
//================================================================================

:- Por favor, leia o FAQ acima, antes de me enviar emails
/
*/
// Isto irá mostrar na barra de título navegadores e no topo da forma .






$websitename="FAÇA AQUI SEU PEDIDO";

// Allowed file types. Please remember to keep the format of this array, add the file extensions you want
// WITHOUT the dot. Please also be aware that certain file types (such as exe) may contain malware.
$allowtypes=array("zip", "rar", "txt", "doc", "jpg", "png", "gif", "odt", "xml");
// What's your email address? Seperate email addresses with commas for multiple email addresses.
$myemail="EMAIL@EMAIL";
// What priority should the script send the mail? 1 (Highest), 2 (High), 3 (Normal), 4 (Low), 5 (Lowest).
$priority="1";
// Should we allow visitors to attach files? How Many? 0 = Do not allow attachments,
// 1 = allow only 1 file to be attached, 2 = allow two files etc.
$allowattach="0";
// Maximum file size for attachments in KB NOT Bytes for simplicity. MAKE SURE your php.ini can handel it,
// post_max_size, upload_max_filesize, file_uploads, max_execution_time!
// 2048kb = 2MB,       1024kb = 1MB,     512kb = 1/2MB etc..
$max_file_size="1024";
// Maximum file size for all attachments combined in KB. MAKE SURE your php.ini can handel it,
// post_max_size, upload_max_filesize, file_uploads, max_execution_time!
// 2048kb = 2MB,       1024kb = 1MB,     512kb = 1/2MB etc..
$max_file_total="2048";
// Value for the Submit Button
$submitvalue="Enviar Dados";
// Value for the Reset Button
$resetvalue=" Limpar Dados";
// Default subject? This will be sent if the user does not type in a subject
$defaultsubject="Sem assunto";
// Because many requested it, this feature will add a drop down box for the user to select a array of
// subjects that you specify below.
// True = Use this feature, False = do not use this feature
$use_subject_drop=false;
// This is an array of the email subjects the user can pick from. Make sure you keep the format of
// this array or you will get errors.
// Look at <[url=http://novahq.net/forum/showthread.php?t=38718]http://novahq.net/forum/showthread.php?t=38718 [/url]> for examples on how to use this feature.
$subjects=array("Department 1", "Department 2", "Department 3");
// This is an array of the email addresses for the array above. There must be an email FOR EACH

// array value specified above. You can have only 1 department if you want.

// YOU MUST HAVE THE SAME AMMOUNT OF $subjects and $emails or this WILL NOT work correctly!

// The emails also must be in order for what you specify above!

// Seperate email addresses by a comma to send an email to multiple addresses.

$emails=array("dept_1@domain.com", "dept_2@domain.com", "dept_3@domain.com");

// This is the message that is sent after the email has been sent. You can use html here.

// If you want to redirect users to another page on your website use this:

// <script type=\"text/javascript\">window.location=\"[url=http://www.jcimoveisbrasil.com/index.php%5C]http://www.jcimoveisbrasil.com/index.php\'>http://www.jcimoveisbrasil.com/index.php\ [/url]":>
$thanksmessage="Mensagem enviado com Sucesso ...Aguarde o nosso retorno. Obrigado.";
/*
//================================================================================
* ! ATTENTION !
//================================================================================
: Não edite abaixo desta linha.

*/
// Função para obter a extensão do arquivo enviado.

function get_ext($key) {
$key=strtolower(substr(strrchr($key, "."), 1));
$key=str_replace("jpeg", "jpg", $key);
return $key;
}
// Função utilizada para anexar arquivos à mensagem


function phattach($file, $name, $boundary) {
$fp=fopen($file, "r");
$str=fread($fp, filesize($file));
$str=chunk_split(base64_encode($str));
$message="--".$boundary."\n";
$message.="Content-Type: application/octet-stream; name=\"".$name."\"\n";
$message.="Content-disposition: attachment; filename=\"".$name."\"\n";
$message.="Content-Transfer-Encoding: base64\n";
$message.="\n";
$message.="$str\n";
$message.="\n";
return $message;
}
//Um pouco de segurança de pessoas forjando cabeçalhos. As pessoas são más , por vezes, :(
function clean_msg($key) {
$key=str_replace("\r", "", $key);
$key=str_replace("\n", "", $key);
$find=array(
"/bcc\:/i",
"/Content\-Type\:/i",
"/Mime\-Type\:/i",
"/cc\:/i",
"/to\:/i"
);
$key=preg_replace($find, "", $key);
return $key;
}
// Initilize algumas variáveis

$error="";
$sent_mail=false;
// Quando o formulário é enviado

If($_POST['submit']==true) {
extract($_POST, EXTR_SKIP);
// Verifique a forma de erros


If(trim($yourname)=="") {
$error.="Preencha o campo Nome!<br />";
}
        Elseif(!preg_match("/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/", $youremail)) {
$error.="Email Inválido.<br />";
}
If(trim($emailsubject)=="") {
$emailsubject=$defaultsubject;
}
If(trim($yourtelefone)=="") {
$error.="Preencha o campo Telefone!<br />";
}
If(trim($yourimovel)=="") {
$error.="Preencha o campo Tipo de Imóvel!<br />";
}
If(trim($yourdormitorios)=="") {
$error.="Preencha o campo NúmeRO de Dormitórios<br />";
}
If(trim($yourvagas)=="") {
$error.="Preencha o campo Vagas!<br />";
}
If(trim($youracabamento)=="") {
$error.="Preencha o campo Preferências de Acabamento!<br />";
}
If(trim($yourescritura)=="") {
$error.="Preencha o campo Imóvel com Escritura!<br />";
}
If(trim($youriptu)=="") {
$error.="Preencha o campo Financiamento Bancário!<br />";
}
If(trim($yourfinanciado)=="") {
$error.="Preencha o campo Preferência de Região!<br />";
}
If(trim($yourlocalidade)=="") {
$error.="Preencha o campo Fins Comerciais ou Resid!<br />";
}
If(trim($yourcidade)=="") {
$error.="Preencha o campo Compra ou Locação!<br />";
}
If(trim($yourvalor)=="") {
$error.="Preencha o campo Valor!<br/>";
}
If(trim($yoursite)=="") {
$error.="Preencha o campo Nosso site!<br />";
}
If(trim($yourmessage)=="") {
$error.="Preencha o campo Mensagem!<br />";
}
//Verifique informações attchment

If($allowattach > 0) {
// Obter o tamanho total de todos os carrega
            
files:
If((array_sum($_FILES['attachment']['size'])) > ($max_file_total*1024)) {

$error.="The max size allowed for all your files is ".$max_file_total."kb<br />";
} Else {

//Loop através de cada um dos arquivos


For($i=0; $i <= $allowattach-1; $i++) {

If($_FILES['attachment']['name'][$i]) {
//Verifique se o tipo de arquivo enviado é um tipo de arquivo válido
If(!in_array(get_ext($_FILES['attachment']['name'][$i]), $allowtypes)) {

$error.= "Invaid file type for your file: ".$_FILES['attachment']['name'][$i]."<br />";

//Verifique o tamanho de cada arquivo

} Elseif(($_FILES['attachment']['size'][$i]) > ($max_file_size*1024)) {
$error.= "Your file: ".$_FILES['attachment']['name'][$i]." is to big.<br />";
} // Se in_array
} // Se Arquivos

} // Para
} // Array_sum mais ( $ _FILES [' anexo' ] [ 'size'] )

} // If Allowattach
If($error) {
$display_message=$error;
} Else {

If($use_subject_drop AND is_array($subjects) AND is_array($emails)) {
$subject_count=count($subjects);
$email_count=count($emails);

If($subject_count==$email_count) {
$myemail=$emails[$emailsubject];
$emailsubject=$subjects[$emailsubject];
} // If $subject_count
} // If $use_subject_drop

$boundary=md5(uniqid(time()));

//Headers
        
$message= $navegador = $_SERVER['HTTP_USER_AGENT'];
$message= $date = date("d/m/Y h:i");
$message= $ip = getenv ("REMOTE_ADDR");
$headers.="Return-Path: <".clean_msg($youremail).">\n";
$headers.="From: ".utf8_decode($yourname)." <".clean_msg($youremail).">\n";
$headers.="X-Mailer: PHP/".phpversion()."\n";
$headers.="X-Sender: ".$_SERVER['REMOTE_ADDR']."\n";
$headers.="X-Priority: ".$priority."\n";
$headers.="MIME-Version: 1.0\n";
$headers.="Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n";
$headers.="This is a multi-part message in MIME format.\n";

//Message

$message = "--".$boundary."\n";

$message.="Content-Type: text/html; charset=utf-8\n";
$message.="Content-Transfer-Encoding: quoted-printable\n";

$message.="\n";
$message.= "<strong>   ***   Novo Pedido de Imóvel   ***   :</strong><br /><br />";
$message.="\n";
print ("$var \n");


$message.="\n";
$message.= "<strong>Data da Mensagem:</strong> $date<br /><br />";
$message.="\n";
print ("$var \n");

$message.= "<br /><br />";
$message.="\n";
print ("$var \n");
$message.= "<strong>Nome:</strong> $yourname<br /><br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Email:</strong> $youremail<br /><br />";
$message.="\n";
print ("$var \n");
$message.="\n";
$message.= "<strong>Telefone:</strong> $yourtelefone<br /><br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Tipo de Imóvel:</strong> $yourimovel<br /><br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Número de Dormitórios:</strong> $yourdormitorios<br /><br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Número de Vagas:</strong> $yourvagas<br /><br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Preferência de Acabamento (sim/não):</strong> $youracabamento<br /><br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Preferência de escritura (sim/não):</strong> $yourescritura<br /><br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Financiamento Bancário (sim/não):</strong> $youriptu<br /><br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Preferência de Região:</strong> $yourfinanciado<br /><br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Para Fins Comerciais:</strong> $yourlocalidade<br /><br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Para Compra ou Locação:</strong> $yourcidade<br /><br />";
$message.="\n";
 print ("$var \n");

$message.= "<strong>Valor:</strong> $yourvalor<br /><br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Como conheceu nosso site:</strong> $yoursite<br /><br />";
$message.="\n";
print ("$var \n");

$message.= "<strong>Mensagem:</strong> $yourmessage<br /><br />";
$message.="\n";
print ("$var \n");
        
$message.= "<strong> IP do Visitante:</strong> $ip<br /><br />";
$message.="\n";
print ("$var \n");

$message.= "<strong> Navegador do Visitante:</strong> $navegador<br /><br />";
$message.="\n";
print ("$var \n");

//Add attachments to message
If($allowattach > 0) {
For($i=0; $i <= $allowattach-1; $i++) {
If($_FILES['attachment']['tmp_name'][$i]) {

$message.=phattach($_FILES['attachment']['tmp_name'][$i], $_FILES['attachment']['name'][$i], $boundary);

} //If $_FILES['attachment']['name'][$i]

} //For

} // If

// End the message

$message.="--".$boundary."--\n";
// Send the completed message

If(!mail($myemail, clean_msg($emailsubject), $message, $headers)) {

Exit("An error has occured, please report this to
the website administrator.\n");

} Else {

$sent_mail=true;
}
} // Else
} // $_POST
/*

//================================================================================
* Start the form layout
//================================================================================
:- Use the html below to customize the form.
*/
}
?>
 
// INÍCIO SCRIPT AUTO RESPOSTA PARA O USUÁRIO.
<?php
$para = "EMAIL@EMAIL";
$assunto = "Mensagem Automática da Jc Imóveis Brasil";
$data = date('d/m/Y H:i');
$mensagem = "
<html>
<meta http-equiv='Content-Type' Content-Type' content='text/html; charset=utf-8'>
<head>
<title>JC IMÓVEIS</title>
</head>
<body>
<p><strong>Resposta Automática da Jc Imóveis Brasil </strong></p>

<p><strong>OBRIGADO POR FAZER O PEDIDO DO IMÓVEL CONOSCO EM BREVE RETORNAREMOS PARA MAIORES DETALHES.... </p>
<p>ATENCIOSAMENTE JC IMÓVEIS BRASIL. </strong> </p>
<table>ACESSE NOSSO SITE <br /><a href=\"[url=]http://www.jcimoveisbrasil.com\index.php\'>http://www.jcimoveisbrasil.com\index.php\ [/url]">[url=http://www.jcimoveisbrasil.com]http://www.jcimoveisbrasil.com [/url]</a>
<p><strong> </strong></p>
<a href=\"[url=]http://www.jcimoveisbrasil.com\index.php\'>http://www.jcimoveisbrasil.com\index.php\ [/url]">
<td><a href='[url=http://www.jcimoveisbrasil.com/]http://www.jcimoveisbrasil.com/ [/url]'><img src='[url=http://www.jcimoveisbrasil.com/]http://www.jcimoveisbrasil.com/ [/url]'/></a></td>
</tr>
</table>
</body>
</html>
<br />
<br />
Enviado em: $data
";
$headers_ = "MIME-Version: 1.0\r\n";
$headers = "Content-Type: text/html; charset=utf-8\r\n";
$headers = "From: $para\r\n";
$headers .= "Content-Type: text/html; charset=utf-8\r\n";
mail($youremail,mb_encode_mimeheader($assunto),$mensagem,$headers);
?>
// FIM SCRIPT AUTO RESPOSTA PARA O USUÁRIO.
 

 

 

 

 

Sei que vão achar um código gigante mas funciona, menos os caracteres especiais quando chegam ao remetente, e obrigado pela atenção.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Um erro que achei foi aqui

$headers_ = "MIME-Version: 1.0\r\n";
$headers = "Content-Type: text/html; charset=utf-8\r\n";
$headers = "From: $para\r\n";
$headers .= "Content-Type: text/html; charset=utf-8\r\n";
mail($youremail,mb_encode_mimeheader($assunto),$mensagem,$headers);

o correto seria


$headers = "MIME-Version: 1.0\r\n"; 
$headers .= "From: $para\r\n"; 
$headers .= "Content-Type: text/html; charset=utf-8\r\n";
mail($youremail,$assunto,$mensagem,$headers);

Agora seu texto está todo em unicode 8bits, não havendo nenhuma decodificação ira enviar como está.

 

O correto é escrever normalmente, e para isso que este padrão UTF-8 surgiu!

 

 

Resposta Automática da Jc Imóveis Brasil

 

Correto

 

Resposta Automática da Jc Imóveis Brasil

 

E ter a codificação de seus scripts em utf-8 (sem BOM)

 

http://rberaldo.com.br/problemas-com-codificacao-acentos-nao-interpretados/

Compartilhar este post


Link para o post
Compartilhar em outros sites

Pow amigão obrigado por responder. eu vou tentar, mas acabei migrando para o php mailer, porque tbm que os servidores dão mais atenção e não envia as msgs para o spam vou tentar mudar isso. e posto depois.



Então Williams Duarte, fiz o qque vc me orientou e agora no remetente lá no email o nome chega assim no assunto la no email "DĂŠbora Carvalho",mas na verdade ou irei abortar o uso d da função email () para usar a classe phpmailer, e aproveitando e peguei uns códigos e montei um formulário conforme minhas necessidades, vou explicar detalalhado porque não achei nenhuma solução ainda na net para meu problema segue o scripts abaixo.

 

o index.php

 

 

<form method="post" id="contactform" action="pedido2.php" enctype="multipart/form-data" name="phmailer" onsubmit="return Checkit(this);">
<table width="593" align="center" class="table">
<tr>
<td colspan="2" class="table_header"></td>
</tr>

<tr>
<td class="attach_info" colspan="2">
</td>
</tr>
<tr>
<td class="attach_info" colspan="2">
<center><b>PREENCHA OS DADOS DE SEU IMÓVEL ABAIXO PARA DAR INICIO AO NOSSO TRABALHO:</b></center>
</td>
</tr>
<tr>
<td class="attach_info" colspan="2">
</td>
</tr>

<tr>
<td width="55%" class="table_body">     Seu Nome:</td>
<td width="45%" class="table_body"><input name="nome" type="text" size="20" value="<?php stripslashes(htmlspecialchars (utf8_decode($nome)));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Seu Email:</td>
<td width="45%" class="table_body"><input name="email" type="text" size="20" value="<?php stripslashes(htmlspecialchars($email));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Seu Telefone:</td>
<td width="45%" class="table_body"><input name="telefone" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($telefone));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Tipo de Imóvel:</td>
<td width="45%" class="table_body"><input name="imovel" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($imovel));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Número de Dormitórios:</td>
<td width="45%" class="table_body"><input name="dormitorios" type="text" size="20"value="<?php echo stripslashes(htmlspecialchars($dormitorios));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Número de Vagas:</td>
<td width="45%" class="table_body"><input name="vagas" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($vagas));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Preferência por Acabamento (s/n):</td>
<td width="45%" class="table_body"><input name="acabamento" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($acabamento));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Imóvel de Condomínio ou de Rua:</td>
<td width="45%" class="table_body"><input name="imovelcond" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($imovelcond));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Localidade:
</td>
<td width="45%" class="table_body"><input name="localidade" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($localidade));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Financiamento Bancário (s/n):</td>
<td width="45%" class="table_body"><input name="financiado" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($financiado));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Imóvel Residencial ou Comercial:</td>
<td width="45%" class="table_body"><input name="resid" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($resid));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Para Compra ou Locação:</td>
<td width="45%" class="table_body"><input name="compralocacao" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($compralocacao));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" height="24" class="table_body">     Valor:</td>
<td width="45%" class="table_body"><input name="valor" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($valor));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Como conheceu nosso Site:</td>
<td width="45%" class="table_body"><input name="site" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($site));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="55%" class="table_body">     Assunto:</td>
<td width="45%" class="table_body">

<input name="assunto" type="text" size="20" value="<?php echo stripslashes(htmlspecialchars($assunto));?>" /><span class="error_message">*</span>

</td>
</tr>
<tr>
<td class="attach_info" colspan="2">
</td>
</tr>
<tr>
<td class="attach_info" colspan="2">
</td>
</tr>
<tr>
<td class="attach_info" colspan="2">
</td>
</tr>
<tr>
<td width="55%" class="table_body">     Adicione Fotos</td>
<td width="45%" class="table_body">
<br />


<input type="file" name="arquivo_1" autofocus="autofocus" />
<br /><br />
<input type="file" name="arquivo_2" autofocus="autofocus" />
<br /><br />
<input type="file" name="arquivo_3" autofocus="autofocus" />
<br /><br />
<input type="file" name="arquivo_4" autofocus="autofocus" />
<br /><br />

<input type="file" name="arquivo_5" autofocus="autofocus" />
<br /><br />
<input type="file" name="arquivo_6" autofocus="autofocus" />
<br /><br />
<input type="file" name="arquivo_7" autofocus="autofocus" />
<br /><br />
<input type="file" name="arquivo_8" autofocus="autofocus" />
<br /><br />
<input type="file" name="arquivo_9" autofocus="autofocus" />
<br /><br />
<input type="file" name="arquivo_10" autofocus="autofocus" />
<br /><br />
<input type="file" name="arquivo_11" autofocus="autofocus" />
<br /><br />
<input type="file" name="arquivo_12" autofocus="autofocus" />
<br /><br />


</td>
</tr>

<tr>
<td colspan="2" class="table_body">          
<div align="center">Preencha mais informações sobre o Imóvel<span class="error_message">*</span><br />
</div>
<div align="center">
<table width="463" border="0">
<tr>
<td width="45"> </td>
<td width="361"><h8>

</h8></td>
<td width="43"> </td>
</tr>
</table>
<textarea name="mensagem" rows="8" cols="60"><?php echo stripslashes(htmlspecialchars($mensagem));?></textarea>
<br />
<div align="center">Digite aqui os caracteres abaixo</div>
<?php
require_once('recaptchalib.php');
// Get a key from https://www.google.com/recaptcha/admin/create
$publickey = " ";
$privatekey = " ";
# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;
# was there a reCAPTCHA response?
if ($_POST["recaptcha_response_field"]) {
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

if ($resp->is_valid) {
echo "You got it!";
} else {
# set the error code so that we can display it
$error = $resp->error;
}

}
echo recaptcha_get_html($publickey, $error);
?>
<br />
</div>
</td>
</tr>
<tr>
<td colspan="2" class="table_footer">
<tr>
<td class="attach_info" colspan="2" >
<table width="542" border="0">
<tr>
<td width="137"> </td>
<td width="182">













<input id="arquivo_1" name="arquivo_1" type="file" multiple="true">





<input type="hidden" name="acao" value="enviar" />
<input type="submit" value="Enviar Formulário" class="btn"/>

</td>
<td width="17">


</td>
<td width="173">

<input type="reset" value="Limpar Dados" />

</td>
<td width="11"> </td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</form>



<a href="javascript:$('#arquivo_1').uploadify('cancel')">Cancel First File</a> | <a href="javascript:$('#arquivo_1').uploadify('upload', '*')">Upload the Files</a>

<script type="text/javascript">
<?php $timestamp = time();?>


$(function() {
$('#arquivo_1').uploadify({
'formData' : {
'timestamp' : '<?php echo $timestamp;?>',
'token' : '<?php echo md5('unique_salt' . $timestamp);?>'
},
'swf' : 'uploadify.swf',
'uploader' : 'pedido2.php',
'cancelImg' : 'cancel.png',
'width' : '100',
'height' : '25',
'folder' : 'temp',
'buttonText': 'Selecionar',
'fileDesc': 'Image Files',
'fileExt': '*.jpg;*.jpeg;*.gif;*.png',
'fileDesc': 'Image Files',
'folder' : '/uploads',
'onComplete': function(event, queueID, fileObj, response, data){
sucesso(response);},
'removeCompleted': false,//Diretório, para onde vão ser movidas as imagens.
'auto' : true, // False para não começar automaticamente, e True para começar o upload automaticamente.
'multi' : true, // False para fazer upload apenas de um arquivo e True para vários arquivos.
'scriptData' : {'$arquivo_1':$('#arquivo_1').val() }

});
});
</script>

 

 

 

 

e o pedido.php o arquivo que envia os dados

 




<?php
/*
Uploadify
Copyright © 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/

// Define a destination
$targetFolder = 'uploads'; // Relative to the root

$verifyToken = md5('unique_salt' . $_POST['timestamp']);

if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['uploads'] . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];

// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);

if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
echo '1';
} else {
echo 'Invalid file type.';
}
}
?>


<?php


$nome = strip_tags(trim (utf8_decode($_POST['nome'])));
$email = strip_tags(trim(utf8_decode($_POST['email'])));
$telefone = strip_tags(trim (utf8_decode($_POST['telefone'])));
$imovel = strip_tags(trim (utf8_decode($_POST['imovel'])));
$dormitorios = strip_tags(trim (utf8_decode($_POST['dormitorios'])));
$vagas = strip_tags(trim (utf8_decode($_POST['vagas'])));
$acabamento = strip_tags(trim (utf8_decode($_POST['acabamento'])));
$imovelcond = strip_tags(trim (utf8_decode($_POST['imovelcond'])));
$localidade = strip_tags(trim (utf8_decode($_POST['localidade'])));
$financiado = strip_tags(trim(utf8_decode($_POST['financiado'])));
$resid = strip_tags(trim (utf8_decode($_POST['resid'])));
$compralocacao = strip_tags(trim (utf8_decode($_POST['compralocacao'])));
$valor = strip_tags(trim (utf8_decode($_POST['valor'])));
$site = strip_tags(trim (utf8_decode($_POST['site'])));
$assunto = strip_tags(trim (utf8_decode($_POST['assunto'])));
$mensagem = strip_tags(trim (utf8_decode($_POST['mensagem'])));
$arquivo_1 = $_FILES['arquivo_1'];
$arquivo_2 = $_FILES['arquivo_2'];
$arquivo_3 = $_FILES['arquivo_3'];
$arquivo_4 = $_FILES['arquivo_4'];
$arquivo_5 = $_FILES['arquivo_5'];
$arquivo_6 = $_FILES['arquivo_6'];
$arquivo_7 = $_FILES['arquivo_7'];
$arquivo_8 = $_FILES['arquivo_8'];
$arquivo_9 = $_FILES['arquivo_9'];
$arquivo_10 = $_FILES['arquivo_10'];
$arquivo_11 = $_FILES['arquivo_11'];
$arquivo_12 = $_FILES['arquivo_12'];
{

$tamanho = 512000;
$tipos = array('image/jpeg', 'image/pjpeg');

if(empty($nome)){
echo "<script>alert('** Preenche o campo nome **');</script>";
echo "<script language='javascript'>history.back()</script>";
}elseif(!filter_var($email, FILTER_VALIDATE_EMAIL)){
echo "<script>alert('** Preenche o campo email **');</script>";
echo "<script language='javascript'>history.back()</script>";

}elseif(empty($mensagem)){
echo "<script>alert('** Preenche o campo mensagem **');</script>";
$msg = 'A Mensagem é Obrigatória';
echo "<script language='javascript'>history.back()</script>";

}elseif($arquivo['size'] > $tamanho){
$msg = 'O limite do tamanho do arquivo é de 500KB';
echo "<script language='javascript'>history.back()</script>";
}

elseif(!in_array($arquivo_1["type"], $tipos) and !empty($arquivo_1['tmp_name'])){

echo "<script>alert('** O arquivo 1 é inválido , são permitido apenas arquivos JPEG **');</script>";
echo "<script language='javascript'>history.back()</script>";
}
elseif(!in_array($arquivo_2["type"], $tipos) and !empty($arquivo_2['tmp_name'])){
echo "<script>alert('** O arquivo 2 é inválido , são permitido apenas arquivos JPEG **');</script>";
echo "<script language='javascript'>history.back()</script>";
}elseif(!in_array($arquivo_3["type"], $tipos) and !empty($arquivo_3['tmp_name'])){
echo "<script>alert('** O arquivo 3 é inválido , são permitido apenas arquivos JPEG **');</script>";
echo "<script language='javascript'>history.back()</script>";
}
elseif(!in_array($arquivo_4["type"], $tipos) and !empty($arquivo_4['tmp_name'])){
echo "<script>alert('** O arquivo 4 é inválido , são permitido apenas arquivos JPEG **');</script>";
echo "<script language='javascript'>history.back()</script>";
}
elseif(!in_array($arquivo_5["type"], $tipos) and !empty($arquivo_5['tmp_name'])){
echo "<script>alert('** O arquivo 5 é inválido , são permitido apenas arquivos JPEG **');</script>";
echo "<script language='javascript'>history.back()</script>";
}
elseif(!in_array($arquivo_6["type"], $tipos) and !empty($arquivo_6['tmp_name'])){
echo "<script>alert('** O arquivo 6 é inválido , são permitido apenas arquivos JPEG **');</script>";
echo "<script language='javascript'>history.back()</script>";
}
elseif(!in_array($arquivo_7["type"], $tipos) and !empty($arquivo_7['tmp_name'])){
echo "<script>alert('** O arquivo 7 é inválido , são permitido apenas arquivos JPEG **');</script>";
echo "<script language='javascript'>history.back()</script>";
}
elseif(!in_array($arquivo_8["type"], $tipos) and !empty($arquivo_8['tmp_name'])){
echo "<script>alert('** O arquivo 8 é inválido , são permitido apenas arquivos JPEG **');</script>";
echo "<script language='javascript'>history.back()</script>";
}
elseif(!in_array($arquivo_9["type"], $tipos) and !empty($arquivo_9['tmp_name'])){
echo "<script>alert('** O arquivo 9 é inválido , são permitido apenas arquivos JPEG **');</script>";
echo "<script language='javascript'>history.back()</script>";
}
elseif(!in_array($arquivo_10["type"], $tipos) and !empty($arquivo_10['tmp_name'])){
echo "<script>alert('** O arquivo 10 é inválido , são permitido apenas arquivos JPEG **');</script>";
echo "<script language='javascript'>history.back()</script>";
}
elseif(!in_array($arquivo_11["type"], $tipos) and !empty($arquivo_11['tmp_name'])){
echo "<script>alert('** O arquivo 11 é inválido , são permitido apenas arquivos JPEG **');</script>";
echo "<script language='javascript'>history.back()</script>";
}
elseif(!in_array($arquivo_12["type"], $tipos) and !empty($arquivo_12['tmp_name'])){
echo "<script>alert('** O arquivo 12 é inválido , são permitido apenas arquivos JPEG **');</script>";
echo "<script language='javascript'>history.back()</script>";

}

else{



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

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Port = 587;
$mail->Host = 'smtp.uol.com.br';
$mail->Username = 'email';
$mail->Password = 'senha';
$mail->SetFrom('email', "$nome");
$mail->AddAddress(' email', "$nome");
$mail->Subject = 'Formulário de Contato';

 

$mail->AddAttachment('');






$body = "

<table width='100%' border='1'>
<tr>
<th width='34%' scope='row'><strong>Nome :</strong> </th>
<th width='66%' scope='row'>{$nome}</th>
</tr>
<tr>
<th scope='row'><strong> E-mail :</strong></th>
<th scope='row'>{$email}</th>
</tr>
<tr>
<th scope='row'><strong> Telefone :</strong></th>
<th scope='row'>{$telefone}</th>
<tr>
<th scope='row'><strong> Imóvel :</strong></th>
<th scope='row'>{$imovel}</th>
</tr>
<tr>
<th scope='row'><strong> Dormitórios :</strong></th>
<th scope='row'>{$dormitorios}</th>
<tr>
<th scope='row'><strong> Vagas :</strong></th>
<th scope='row'>{$vagas}</th>
</tr>
<tr>
<th scope='row'><strong> Imóvel de Condomínio ou de Rua:</strong></th>
<th scope='row'>{$imovelcond}</th>
<tr>
<th scope='row'><strong> Localidade :</strong></th>
<th scope='row'>{$localidade}</th>
</tr>
<tr>
<th scope='row'><strong> Financiado :</strong></th>
<th scope='row'>{$financiado}</th>
<tr>
<th scope='row'><strong> Residencial ou Comercial :</strong></th>
<th scope='row'>{$resid}</th>
</tr>
<tr>
<th scope='row'><strong> Compra ou Locação :</strong></th>
<th scope='row'>{$compralocacao}</th>
<tr>
<th scope='row'><strong> Valor :</strong></th>
<th scope='row'>{$valor}</th>
</tr>
<tr>
<th scope='row'><strong> Site :</strong></th>
<th scope='row'>{$site}</th>
<tr>
<th scope='row'><strong> Assunto :</strong></th>
<th scope='row'>{$assunto}</th>
</tr>
<tr>
<th scope='row'><strong> Mensagem :</strong></th>
<th scope='row'>{$mensagem}</th>
<tr>
<th scope='row'> </th>
<th scope='row'> </th>
</tr>

</table>


<table width='100%' border='1'>
<tr>
<td><div align='center'><strong> Fotos </strong></div></td>
</tr>
</table>

<table width='100%' border='1'>
<tr>
<th width='11%' scope='row'> </th>
<th width='22%' scope='row'> </th>
<th width='67%' scope='row'> </th>
</tr>

<tr>
<th scope='row'> </th>
<th scope='row'> </th>
<th scope='row'> </th>
</tr>


<tr>
<th scope='row'><strong>Arquivo1 </strong> </th>
<th scope='row'>".$arquivo_1['name']."<br /><br /></th>
<th scope='row'>





</th>
</tr>
<tr>
<th scope='row'><strong>Arquivo2 </strong> </th>
<th scope='row'>".$arquivo_2['name']."<br /><br /></th>
<th scope='row'> </th>
</tr>
<tr>
<th scope='row'><strong>Arquivo3 </strong> </th>
<th scope='row'>".$arquivo_3['name']."<br /><br /></th>
<th scope='row'> </th>
</tr>
<tr>
<th scope='row'><strong>Arquivo4 </strong> </th>
<th scope='row'>".$arquivo_4['name']."<br /><br /></th>
<th scope='row'> </th>
</tr>
<tr>
<th scope='row'><strong>Arquivo5 </strong> </th>
<th scope='row'>".$arquivo_5['name']."<br /><br /></th>
<th scope='row'> </th>
</tr>
<tr>
<th scope='row'><strong>Arquivo6 </strong> </th>
<th scope='row'>".$arquivo_6['name']."<br /><br /></th>
<th scope='row'> </th>
</tr>
<tr>
<th scope='row'><strong>Arquivo7 </strong> </th>
<th scope='row'>".$arquivo_7['name']."<br /><br /></th>
<th scope='row'> </th>
</tr>
<tr>
<th scope='row'><strong>Arquivo8 </strong> </th>
<th scope='row'>".$arquivo_8['name']."<br /><br /></th>
<th scope='row'> </th>
</tr>
<tr>
<th scope='row'><strong>Arquivo9 </strong> </th>
<th scope='row'>".$arquivo_9['name']."<br /><br /></th>
<th scope='row'> </th>
</tr>
<tr>
<th scope='row'><strong>Arquivo10 </strong> </th>
<th scope='row'>".$arquivo_10['name']."<br /><br /></th>
<th scope='row'> </th>
</tr>
<tr>
<th scope='row'><strong>Arquivo11 </strong> </th>
<th scope='row'>".$arquivo_11['name']."<br /><br /></th>
<th scope='row'> </th>
</tr><tr>
<th scope='row'><strong>Arquivo12 </strong> </th>
<th scope='row'>".$arquivo_12['name']."</th>
<th scope='row'> </th>
</tr>

<tr>
<th scope='row'> </th>
<th scope='row'> </th>
<th scope='row'> </th>
</tr>

</table>"

$mail->MsgHTML($body);

if(file_exists($arquivo_1["tmp_name"]) and !empty($arquivo_1)){
$mail->AddAttachment($_FILES['arquivo_1']['tmp_name'], $_FILES['arquivo_1']['name']);
}


if(file_exists($arquivo_2["tmp_name"]) and !empty($arquivo_2)){

$mail->AddAttachment($_FILES['arquivo_2']['tmp_name'], $_FILES['arquivo_2']['name']);
}
if(file_exists($arquivo_3["tmp_name"]) and !empty($arquivo_3)){
$mail->AddAttachment($_FILES['arquivo_3']['tmp_name'], $_FILES['arquivo_3']['name']);
}
if(file_exists($arquivo_4["tmp_name"]) and !empty($arquivo_4)){
$mail->AddAttachment($_FILES['arquivo_4']['tmp_name'], $_FILES['arquivo_4']['name']);
}

if(file_exists($arquivo_5["tmp_name"]) and !empty($arquivo_5)){
$mail->AddAttachment($_FILES['arquivo_5']['tmp_name'], $_FILES['arquivo_5']['name']);
}
if(file_exists($arquivo_6["tmp_name"]) and !empty($arquivo_6)){
$mail->AddAttachment($_FILES['arquivo_6']['tmp_name'], $_FILES['arquivo_6']['name']);
}
if(file_exists($arquivo_7["tmp_name"]) and !empty($arquivo_7)){
$mail->AddAttachment($_FILES['arquivo_7']['tmp_name'], $_FILES['arquivo_7']['name']);
}
if(file_exists($arquivo_8["tmp_name"]) and !empty($arquivo_8)){
$mail->AddAttachment($_FILES['arquivo_8']['tmp_name'], $_FILES['arquivo_8']['name']);
}
if(file_exists($arquivo_9["tmp_name"]) and !empty($arquivo_9)){
$mail->AddAttachment($_FILES['arquivo_9']['tmp_name'], $_FILES['arquivo_9']['name']);
}
if(file_exists($arquivo_10["tmp_name"]) and !empty($arquivo_10)){
$mail->AddAttachment($_FILES['arquivo_10']['tmp_name'], $_FILES['arquivo_10']['name']);
}
if(file_exists($arquivo_11["tmp_name"]) and !empty($arquivo_11)){
$mail->AddAttachment($_FILES['arquivo_11']['tmp_name'], $_FILES['arquivo_11']['name']);
}
if(file_exists($arquivo_12["tmp_name"]) and !empty($arquivo_12)){
$mail->AddAttachment($_FILES['arquivo_12']['tmp_name'], $_FILES['arquivo_12']['name']);
}

if($mail->Send())

{
}

}

?>
Willlians este script que adaptei funciona legal, veja os campos inputs file de ulpoads acima que funciona normalmente e sem erros de caracteres especiais, mas voce deve ter notado que o uso o ** uploadify ** com mult-uploads um único botão abaixo, o que que queria era eliminar todos aqueles inputs file padrão e deixar apenas o uploadify que é bem melhor e têm barra de progresso, eu até consegui adaptá-lo nesse formulário e ele envia normalmente os arquivos para a pasta no servidor só que eu queria para ficar completo é que ao mesmo tempo que ele envia para o servidor ele tbm enviasse para meu email tipo assim, quando o usuário enviar as fotos do imóvel usando o botão uploadifye ele tbm enviasse para eu email resgatando dos dois lados os arquivos, essa função que ainda não consegui criar desde já agradeço .



Acabei esquecendo para visualizar a pagina com ficou esta neste endereço

 

http://www.jcimoveisbrasil.com/cadastrodeimoveis/index.php

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.