PHP编码希腊语

时间:2016-11-02 11:14:01

标签: php html encoding

我有一个用我的php邮件文本编码与希腊字母的promlem。

当有人用希腊语向我发送电子邮件时,我会收到这样的信息......

来自:Î|ÎÎÎÎÎÎÎÎÏ,Î'ÎÎÎÎÏÏÏÏÏÏÏÎÎÎ  电子邮件:  信息:  Ïα±ÎÏÏ“ÎμβοÏ...

请有人帮忙!

我的php是:

$to = 'info@someone.gr';  // please change this email id


$errors = array();
// print_r($_POST);

// Check if name has been entered
if (!isset($_POST['name'])) {
    $errors['name'] = 'Please enter your name';
}

// Check if email has been entered and is valid
if (!isset($_POST['email']) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
    $errors['email'] = 'Please enter a valid email address';
}

//Check if message has been entered
if (!isset($_POST['message'])) {
    $errors['message'] = 'Please enter your message';
}

$errorOutput = '';

if(!empty($errors)){

    $errorOutput .= '<div class="alert alert-danger alert-dismissible" role="alert">';
    $errorOutput .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>';

    $errorOutput  .= '<ul>';

    foreach ($errors as $key => $value) {
        $errorOutput .= '<li>'.$value.'</li>';
    }

    $errorOutput .= '</ul>';
    $errorOutput .= '</div>';

    echo $errorOutput;
    die();
}



$name = $_POST['name'];
$email = $_POST['email'];
    $message = $_POST['message'];
$from = $email;
$subject = 'Contact Form : someone.gr';






$body = "From: $name\n E-Mail: $email\n Message:\n $message";


//send the email
$result = '';
if (mail ($to, $subject, $body)) {
    $result .= '<div class="alert alert-success alert-dismissible" role="alert">';
    $result .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>';
    $result .= 'Thank You! I will be in touch';
    $result .= '</div>';

    echo $result;
    die();
}

$result = '';
$result .= '<div class="alert alert-danger alert-dismissible" role="alert">';
$result .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>';
$result .= 'Something bad happend during sending this message. Please try again later';
$result .= '</div>';

echo $result;
die();

1 个答案:

答案 0 :(得分:-1)

我认为此代码不完整..您是否在标题中设置了正确的字符集?

$headers = "Content-Type: text/html; charset=UTF-8";