note 69129 deleted from function.mail by cmb
| From: | cmb@php.net | Date: | Sun, 21 Jul 2019 08:29:19 +0000 |
| Subject: | note 69129 deleted from function.mail by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-211637@lists.php.net to get a copy of this message | ||
Note Submitter: thomas at p-devion dot de
----
Change the function addattachment for multipartmail to auto detect the mime_content_type ...
<?php
function addattachment($file){
$fname = substr(strrchr($file, "/"), 1);
$data = file_get_contents($file);
$i = count($this->parts);
$content_id = "part$i." . sprintf("%09d", crc32($fname)) .
strrchr($this->to_address, "@");
$this->parts[$i] = "Content-Type: ".mime_content_type($file).";
name=\"$fname\"\r\n" .
"Content-Transfer-Encoding: base64\r\n" .
"Content-ID: <$content_id>\r\n" .
"Content-Disposition: inline;\n" .
" filename=\"$fname\"\r\n" .
"\n" .
chunk_split( base64_encode($data), 68, "\n");
return $content_id;
}
?>