Jump to content
Fórum Script Brasil
  • 0

Formulário PHP (problemas na acentuação no email)


nicolasdezena
 Share

Question

Galera,

Seguinte, tenho um formulário de contato que deve ser enviado por email, está parte está tudo ok, porém quando recebido o email o mesmo apresenta erros na acentuação colocando os caracteres estranhos. Abaixo segue meu código.

<?php
include 'functions.php';
ini_set('default_charset','UTF-8');
if (!empty($_POST)){
$data['success'] = true;
$_POST = multiDimensionalArrayMap('cleanEvilTags', $_POST);
$_POST = multiDimensionalArrayMap('cleanData', $_POST);
$emailTo ="[email protected]";
$emailFrom ="[email protected]";
$name = utf8_encode($_POST["name"]);
$email = utf8_encode($_POST["email"]);
$comment = utf8_encode ($_POST["comment"]);
$pattern = '/[\r\n]|Content-Type:|Bcc:|Cc:/i';
if (preg_match($pattern, $name) || preg_match($pattern, $email) || preg_match($pattern, $subject)) {
die("Header injection detected");
}
if(!mail($emailTo,$name,$comment, $email, "-r".$emailFrom))
{
// Se for Postfix - hospedagem linux
$headers .= "Return-Path: " . $emailFrom . $quebra_linha;
}
if($name == "")
$data['success'] = false;
if (!preg_match("/^[_\.0-9a-zA-Z-][email protected]([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email))
$data['success'] = false;
if($comment == "")
$data['success'] = false;
if($data['success'] == true){
$message = "NAME: $name<br>
EMAIL: $email<br>
COMMENT: $comment";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= "From: <$emailFrom>" . "\r\n";
mail($emailTo, $emailSubject, $message, $headers);
$data['success'] = true;
echo json_encode($data);
}
}
Obrigado,
Nicolas Dezena
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Forum Statistics

    • Total Topics
      149.8k
    • Total Posts
      646.6k
×
×
  • Create New...