有人可以提供标题列表或有关如何使用附加的csv文件发送邮件的示例吗?
我遇到了麻烦,因为在我发现的每个例子中都有不同的标题。
更新:
private function sendMail(){
$csv = $this->createCSV();
$subject = $this->getMessage('subject');
$message = $this->getMessage('message');
$headers = $this->generateHeaders();
mail('my_mail@gmail.com', $subject, $message, $headers);
// $this->truncate();
}
private function generateHeaders($file){
$boundary = md5(uniqid(time()));
$headers = 'MIME-Version: 1.0'."\r\n";
$headers .= '"Content-Type: multipart/mixed; boundary="'.$boundary."\"\r\n";
$headers .= 'From: noreplay@'.$_SERVER['SERVER_NAME']."\r\n";
$headers .= '--'.$boundary."\r\n";
$headers .= "Content-Type: text/csv; name=\"ImageServersLogs.csv\"\r\n";
$headers .= "Content-Transfer-Encoding: base64\r\n";
$headers .= "Content-Disposition: attachment; filename=\"ImageServersLogs.csv\"\r\n";
$headers .= "\r\n";
$headers .= chunk_split(base64_encode(file_get_contents('/var/www/html/_my.csv')));
$headers .= "\r\n--".$boundary."\r\n";
}