я вот так отправлял свой csv файл сильно не пинайте
public function SendMailCSV($UserMail, $Day)
{
$subject = "тема письма";
$message = $Day ? " day" : " One ";
$filename = "csvarray.csv";
$filepath = $filename;
$boundary = "--" . md5(uniqid(time()));
$mailheaders = "MIME-Version: 1.0;\r\n";
$mailheaders .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n";
$mailheaders .= "From: mandarin \r\n";
$mailheaders .= "Reply-To: $UserMail \r\n";
$multipart = "--$boundary\r\n";
$multipart .= "Content-Type: text/html; charset=windows-1251\r\n";
$multipart .= "Content-Transfer-Encoding: base64\r\n";
$multipart .= "\r\n";
$multipart .= chunk_split(base64_encode(iconv("utf8", "windows-1251", $message)));
$fp = fopen($filepath, "r");
if (!$fp) {
print "Не удается открыть файл22";
exit();
}
$file = fread($fp, filesize($filepath));
fclose($fp);
$message_part = "\r\n--$boundary\r\n";
$message_part .= "Content-Type: application/octet-stream; name=\"$filename\"\r\n";
$message_part .= "Content-Transfer-Encoding: base64\r\n";
$message_part .= "Content-Disposition: attachment; filename=\"$filename\"\r\n";
$message_part .= "\r\n";
$message_part .= chunk_split(base64_encode($file));
$message_part .= "\r\n--$boundary--\r\n";
$multipart .= $message_part;
mail($UserMail, $subject, $multipart, $mailheaders);
// отправляем письмо
unlink($filepath);
}