こんにちは。
ウェブサイトを運営しているものなのですが、
お問い合わせフォームより問い合わせをいただいた際に、
添付ファイルの選択ボタンも設置しており、ウェブ上よりは
添付ファイルを選択して添付ができて、送信するとメッセージは送信されます。
しかし、テストで行ってみると、メールの内容や送信者はは無事に受信ボックスに送信されてくるのですが、
添付ファイルだけが添付されていない状態でメールがきてしまいました。
どこをみて対処すればいいのでしょうか?
sendmail.php内のコードは下記になっております。
<?php $error = 0; $to= "1hightouch@gmail.com"; $senderEmail = filterInput($_POST['email']); $name = filterInput($_POST['name']); $message = filterInput($_POST['message']); $subject = filterInput($_POST['subject']); $attachment = $_FILES['file']['tmp_name']; $attachment_name = $_FILES['file']['name']; die('test'); function filterInput($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } if( isset( $_FILES[ 'file' ] )){ $attachment = chunk_split(base64_encode(file_get_contents($_FILES['file']['tmp_name']))); $filename = $_FILES['file']['name']; $allowed = array('gif','png' ,'jpg'); $filename = $_FILES['file']['name']; $ext = pathinfo($filename, PATHINFO_EXTENSION); if(!in_array($ext,$allowed) ) { ?> <script type="text/javascript"> window.location = 'index.php?error=1'; </script> <?php } if($_FILES["file"]["size"] < 5120000 ) { ?> <script type="text/javascript"> window.location = 'index.php?error=2'; </script> <?php } $_FILES["imagefile"]["size"] < 2120000 $boundary =md5(date('r', time())); $headers = "From: ". $senderEmail ."\r\nReply-To: ". $senderEmail .""; $headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\""; $message .="This is a multi-part message in MIME format. --_1_$boundary Content-Type: multipart/alternative; boundary=\"_2_$boundary\" --_2_$boundary Content-Type: text/plain; charset=\"iso-8859-1\" Content-Transfer-Encoding: 7bit $message --_2_$boundary-- --_1_$boundary Content-Type: application/octet-stream; name=\"$filename\" Content-Transfer-Encoding: base64 Content-Disposition: attachment $attachment --_1_$boundary--"; mail($to, $subject, $message, $headers); }else{ $headers = "From: $senderEmail"; $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}\""; @mail($to, $subject, $message, $headers); } ?> <script type="text/javascript"> window.location = 'index.php?msg=success'; </script>