我有這個小凹凸... 我想發送密件抄送副本,但是當我增加頭文件的數量作爲圖像代碼發送附加文件。不能找到一種方法來發送密碼抄送在這個腳本
這裏是我的代碼:
$to="[email protected]";
$subject="Petición de financiamiento";
$from = stripslashes($_POST['nombre'])."<".stripslashes($_POST['correo']).">";
$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
$headers = "From: $from\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n" .
" boundary=\"{$mime_boundary}\"";
$message="Petición de financiamiento\r\n";
$message .="\r\n";
$message .= "Nombre: ".$_POST["nombre"]."\r\n";
$message .= "Correo: ".$_POST["correo"]."\r\n";
$message .= "Teléfono: ".$_POST["telef"]."\r\n";
$message .="\r\n";
$message .="\r\n";
$message .= $_POST["mensaje"];
$message .="\r\n";
$message .="\r\n";
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
foreach($_FILES as $userfile){
$tmp_name = $userfile['tmp_name'];
$type = $userfile['type'];
$name = $userfile['name'];
$size = $userfile['size'];
if (file_exists($tmp_name)){
if(is_uploaded_file($tmp_name)){
$file = fopen($tmp_name,'rb');
$data = fread($file,filesize($tmp_name));
fclose($file);
$data = chunk_split(base64_encode($data));
}
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$type};\n" .
" name=\"{$name}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n";
}
}
$message.="--{$mime_boundary}--\n";
$message.="--{$mime_boundary}--\n";
if (@mail($to, $subject, $message, $headers))
echo "Mensaje enviado";
else
echo "No se pudo enviar";
任何想法如何添加BCC的,預先感謝您的任何幫助。
如果你已經嘗試了下面的一些答案,但仍然有問題,它看起來像你的問題不是在指定密件抄送,而是在發送attatchments。 看看http://stackoverflow.com/questions/12301358/send-attachments-with-php-mail並考慮切換到PHPMailer。 – MarcM