0

我无法收到我的(图像)上传表单正在发送的电子邮件,以支持拉丁字符。

  $headers .= "\nMIME-Version: 1.0\n" .
                  "Content-Type: multipart/mixed\n" .
                  " boundary=\"{$mime_boundary}\"";


      $message ="This is a multi-part message in MIME format.\n\n";
      $message.="--{$mime_boundary}\n";
      $message.="Content-Type: text/html; charset=utf-8\n";
      $message.="Content-Transfer-Encoding: 7bit\n\n";

有什么想法吗?

抱歉内容太少了,这会更有帮助吗?

    $fileatt      = $_FILES['attachment']['tmp_name'];
    $fileatt_type = $_FILES['attachment']['type'];
    $fileatt_name = $_FILES['attachment']['name'];


    $headers = "From: $emailfrom";


      $semi_rand = md5(time());
      $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";



      $headers .= "\nMIME-Version: 1.0\n" .
                  "Content-Type: multipart/mixed\n" .
                  " boundary=\"{$mime_boundary}\"";




      $subject='Presentación de la fotografía';

      $message ="This is a multi-part message in MIME format.\n\n";
      $message.="--{$mime_boundary}\n";
      $message.="Content-Type: text/html; charset=utf-8\n";
      $message.="Content-Transfer-Encoding: 7bit\n\n";
      $message.="".$namefrom." nos envía este foto.<br />\n\n";

    if (is_uploaded_file($fileatt)) {
      // Read the file to be attached ('rb' = read binary)
      $file = fopen($fileatt,'rb');
      $data = fread($file,filesize($fileatt));
      fclose($file);

      // Base64 encode the file data
      $data = chunk_split(base64_encode($data));


      $message .= "--{$mime_boundary}\n" .
                  "Content-Type: {$fileatt_type};\n" .
                  " name=\"{$fileatt_name}\"\n" .
                  //"Content-Disposition: attachment;\n" .
                  //" filename=\"{$fileatt_name}\"\n" .
                  "Content-Transfer-Encoding: base64\n\n" .
                  $data . "\n\n" .
                  "--{$mime_boundary}--\n";
    }


    $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("Disculpa se ha producido un error. Inténtalo de nuevo. Gracias<");
    } else {
        echo '<div id="formfeedback">'. $thanksmessage .'</div>';
        unset($_SESSION['myForm']);
        print_form();

    }

奇怪的是,当我在我的 Mac 上收到我的测试邮件时,我得到了无效字符,但在我的 iPhone 上却显示正确。

4

2 回答 2

0

以下钉了它

形式:$message.="Content-Type: text/html; charset=utf-8\n"; 在 html 中:<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

我真正改变的唯一一件事是(在 html 元中)将 UTF-8 转换为大写字母。

于 2012-10-22T19:28:36.440 回答
0

使用字符集 ISO-8859-1。它支持西欧、Latin-1。UTF-8 是 ASCII 兼容的多字节 8 位 Unicode。

于 2012-10-22T17:50:18.280 回答