我无法收到我的(图像)上传表单正在发送的电子邮件,以支持拉丁字符。
$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 上却显示正确。