我正在用 .PHP 文件上的 POST 方法制作一个表单,但是当我收到电子邮件时,它有很多奇怪的字符,应该是带重音符号的字母。
它看起来像这样:
<?php
if(isset($_POST['mail'])) {
// CHANGE THE TWO LINES BELOW
$email_to = "alala@alala.com";
$email_subject = "lalala";
// validation expected data exists
if(!isset($_POST['nome']) ||
!isset($_POST['mail']) ||
!isset($_POST['site']) ||
!isset($_POST['autorizacao']) ||
!isset($_POST['banca']) ||
!isset($_POST['descricao']) ||
!isset($_POST['mesa'])) {
died('');
}
$nome = $_POST['nome']; // required
$mail = $_POST['mail']; // required
$telefone = $_POST['telefone']; // required
$site = $_POST['site']; // required
$autorizacao = $_POST['autorizacao']; // required
$banca = $_POST['banca']; // required
$descricao = $_POST['descricao']; // required
$mesa = $_POST['mesa']; // required
$sugestoes = $_POST['sugestoes']; // required
$email_message = "Inscrição para a Showroom:.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Nome: ".clean_string($nome)."\n";
$email_message .= "E-mail: ".clean_string($mail)."\n";
$email_message .= "Email: ".clean_string($telefone)."\n";
$email_message .= "Email: ".clean_string($site)."\n";
$email_message .= "Email: ".clean_string($autorizacao)."\n";
$email_message .= "Email: ".clean_string($banca)."\n";
$email_message .= "Email: ".clean_string($descricao)."\n";
$email_message .= "Email: ".clean_string($mesa)."\n";
$email_message .= "Comments: ".clean_string($sugestoes)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>