Скрипт отправки почты (проблемы с кодировкой входящих сообщений)

Barrell

Новичок
Скрипт отправки почты (проблемы с кодировкой входящих сообщений)

Доброго времени суток, господа.

Для отправки почты был написан следующий скрипт:

PHP:
<?php
class SendLocalMail {
  function SendLocalMail () {
    //
  }
  function CreateMessage ($UserName, $UserEmail, $ProjectName, $Cid, $UserMsg, $SshKey, $UserIp) {
    // Test parameters for true values
    if ($UserName == "") {
      $this->PrintFailed ("Please enter User Name");
      return False;
    }
    if ($ProjectName == "") {
      $this->PrintFailed ("Please enter Project Name");
      return False;
    }
    if (!$this->TestIp ($UserIp)) {
      $this->PrintFailed (""); //FIXME
      return False;
    }
    if (!$this->TestEmailAddress ($UserEmail)) {
      $this->PrintFailed ("Please enter correct email address");
      return False;
    }
    if (!$this->TestSshKey ($SshKey)) {
      $this->PrintFailed ("Please enter correct ssh key");
      return False;
    }
    // Make the message to send
    $Category = ($Cid == 1? "New account request": "Technical question");
    $this->Subject = "<something>".$Category;
    $this->Message = "User ".$UserName."(".$UserEmail.") has requested for the ssh account on server. His project is \"".$ProjectName."\", ssh key is \"".$SshKey."\". And he wrote: ".$UserMsg;
    return true;
  }

  function PrintFailed ($What) {
    echo "Message hasn't beed sent: ".$What."<br>";
  }

  function TestIp ($Ip, $LocalFileName = "IpList") {
    return True;
  }

  // FIXME
  // Add test for ip. When user is trying to send request, add his ip to list and look for ip next time.
  function TestSshKey () {
    return True;
  }

  function TestEmailAddress ($EmailAddress) {
    $pattern = '/.*@.*\..*/';
    if (preg_match($pattern, $EmailAddress) > 0) {
      return True;
    } else {
      return False;
    }
  }

  function Send ($DestAddress) {

    // Send the message
    if (!mail($DestAddress, $this->Subject, $this->Message, "From: <something>"."Reply-To: "E-mail"")) {
      return False;
    } else {
      return True;
    }

  }
}
?>
саму функцию отправки почты он как ни странно выполняет отлично. Единственный вопрос в том, что если на вход в качестве сообщения ему поступает текст написанный кириллицей (кодировка UTF-8) - сообщение приходит в нечитабельной кодировке.

Поскольку с PHP сталкиваться не приходилось достаточно давно, очень нуждаюсь в Ваших советах. Каким Вы видите решение данной проблемы?

Заранее благодарен всем откликнувшимся!
 
Сверху