PHP mail form characters error

Hi, i’m portuguese and my form have to show special characters when send email to outlook, mac mail, etc.
i think that supose to be utf8… and i’ve tried many charset in $headers/$headers2 but nothing works…

[php]if (empty($errors)) { //If everything is OK

	// send an email
	
	// Obtain file upload vars
	$fileatt      = $_FILES['attachment']['tmp_name'];
	$fileatt_type = $_FILES['attachment']['type'];
	$fileatt_name = $_FILES['attachment']['name'];
	
	// Headers
$headers .= 'Content-type: text/html; charset=ANSI' . "\r\n"; 
$headers = "From: $emailfrom";

$headers2 .= 'Content-type: text/html; charset=ANSI' . "\r\n"; 
$headers2 = "From: [email protected]";
	
	// create a boundary string. It must be unique
	  $semi_rand = md5(time());
	  $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

	  // Add a multipart boundary above the plain message

	  $message.="Dados Pessoais\n\n";
	  $message.="De: ".$nome."\n";
	  $message.="Morada: ".$morada."\n";
	  $message.="Código-Postal: ".$codpostal."\n";
	  $message.="Telefone: ".$tlf."\n";

	
	$mensagem2  = "Caro/a " . $nome . "\n";
   $mensagem2.="\n";
   $mensagem2 .= "Obrigado por ter submetido a sua inscrição.\n\n";
   $mensagem2 .= "Melhores cumprimentos.\n";

	if (is_uploaded_file($fileatt)) {
	
	}
	
	
	// Send the completed message
	
	$envia =  mail($emailfrom,"A sua mensagem foi enviada com sucesso",$mensagem2,$headers2);
	$envs = array("HTTP_USER_AGENT", "REMOTE_ADDR", "REMOTE_HOST");
	foreach ($envs as $env)
	$message .= "$env: $_SERVER[$env]\n";
	
	if(!mail($to,$subject,$message,$headers)) {
		exit("Não foi possível enviar a sua mensagem. Reporte o administrador da página.\n");
		echo "<meta http-equiv='refresh' content='5;URL=index.php'>";
	} else {
		echo '<div id="formfeedback"><strong style="color:#9ec960;">Obrigado</strong><p>'. $thanksmessage .'</p></div>';
		echo "<meta http-equiv='refresh' content='5;URL=index.php'>";
		unset($_SESSION['myForm']);
		print_form();
		
	} // end of if !mail[/php]

Help please…
Regards

http://www.webdeveloper.com/forum/showthread.php?116154-e-mail-script-for-SUBJECT-with-special-characters

check out the last post there are links to several answers to your question.

Sponsor our Newsletter | Privacy Policy | Terms of Service