2013-08-25 1 views
0

내 웹 사이트에서 저에게 연락하기위한 양식을 만들었습니다. 나는 웹 사이트에있는 양식을 사용하면히브리어로 된 문의 양식 - 이상한 기호

<?php 
$errors = ''; 
$myemail = '[email protected]';//<-----Put Your email address here. 
if(empty($_POST['name']) || 
    empty($_POST['email']) || 
    empty($_POST['message'])) 
{ 
    $errors .= "\n Error: all fields are required"; 
} 

$name = $_POST['name']; 
$email_address = $_POST['email']; 
$message = $_POST['message']; 

if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", 
$email_address)) 
{ 
    $errors .= "\n Error: Invalid email address"; 
} 

if(empty($errors)) 
{ 
    $to = $myemail; 
    $email_subject = "Contact form submission: $name"; 
    $email_body = "You have received a new message. ". 
    "name: $name \n\n email: $email_address \n\n\n $message"; 

    $headers = "From: $myemail\n"; 
    $headers .= "Reply-To: $email_address"; 

    mail($to,$email_subject,$email_body,$headers); 
    //redirect to the 'thank you' page 
    header('Location: contact_thanks.html'); 
} 
?> 

, 나는 이상한 문자와 메일을 수신 : 이것은 PHP 코드입니다. 왜냐하면 나는 형식으로 히브리어로 글을 쓰기 때문입니다. 영어 글자가 잘 전달됩니다. "myemail"을 다른 메일로 변경하면 히브리어로도 메시지가 잘 전달되지만 메시지를 첫 번째 메일로 전달하려고합니다.

인코딩을 여러 번 변경했지만 아무 것도 문제를 해결하지 못하는 것 같습니다. 아직 정확한 시도를하지 않은 것 같습니다.

나는 코드를 작성한 사람이 아니므로 PHP는 잘 모릅니다. 따라서 이해하기 쉬운 답을주십시오.

답변

2

메일 헤더에 콘텐츠 인코딩을 지정해야합니다. 따라서 다음 줄을 추가하십시오.

$headers .= "\nContent-type: text/html; charset=UTF-8";