I try to send email with attachment, if I use the code:
I can receive email but attatchment will be:
--==Multipart_Boundary_x72b635c7702060d0b1fe1290622e371ex Content-Type: application/x-zip-compressed; name="test.zip" Content-Transfer-Encoding: base64 UEsDBBQAAAAIAK5dgjB7/2sdbgAAAIEAAAAIAAAAdGVzdC5ydGYlyzEOgzAMBdDOSNyBIzihnZi4 hxc3ianVKEWxCwPi7gW6PH19/b9hNXZIReUizJPzD48xMcNppjI56PsN+VPMnvkIgKyrqCKHF1VN Bt1YhfKw722Di6T1LSXe8RsczlTj/+Ghs6R2cdZtc6xvP1BLAQIUABQAAAAIAK5dgjB7/2sdbgAA AIEAAAAIAAAAAAAAAAEAIAC2gQAAAAB0ZXN0LnJ0ZlBLBQYAAAAAAQABADYAAACUAAAAAAA= --==Multipart_Boundary_x72b635c7702060d0b1fe1290622e371ex--
If I change the headers from:
to
I can receive attachment correctly but lose the email contents.
How can I receive both email body and attachment? thanks.
Code:
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: text/html;\n" .
" boundary=\"{$mime_boundary}\"";
$data = chunk_split(base64_encode($data));
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
$message = StripSlashes($message);
mail($to, $subject, $message, $headers);
I can receive email but attatchment will be:
--==Multipart_Boundary_x72b635c7702060d0b1fe1290622e371ex Content-Type: application/x-zip-compressed; name="test.zip" Content-Transfer-Encoding: base64 UEsDBBQAAAAIAK5dgjB7/2sdbgAAAIEAAAAIAAAAdGVzdC5ydGYlyzEOgzAMBdDOSNyBIzihnZi4 hxc3ianVKEWxCwPi7gW6PH19/b9hNXZIReUizJPzD48xMcNppjI56PsN+VPMnvkIgKyrqCKHF1VN Bt1YhfKw722Di6T1LSXe8RsczlTj/+Ghs6R2cdZtc6xvP1BLAQIUABQAAAAIAK5dgjB7/2sdbgAA AIEAAAAIAAAAAAAAAAEAIAC2gQAAAAB0ZXN0LnJ0ZlBLBQYAAAAAAQABADYAAACUAAAAAAA= --==Multipart_Boundary_x72b635c7702060d0b1fe1290622e371ex--
If I change the headers from:
Code:
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: text/html;\n" .
" boundary=\"{$mime_boundary}\"";
Code:
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
I can receive attachment correctly but lose the email contents.
How can I receive both email body and attachment? thanks.