note 76955 added to function.imap-mail-compose
| From: | Freman at osu1 dot php dot net | Date: | Wed, 08 Aug 2007 00:57:59 +0000 |
| Subject: | note 76955 added to function.imap-mail-compose | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129267@lists.php.net to get a copy of this message | ||
Since at least PHP 4.3 the $part[] hash can contain the $part['type.parameters'] which
expects a hash.
Unfortunately for "hans at lintoo dot dk" there doesn't appear to have ever been
$part['parameters.name'] or a $part['dparameters.filename']
So it would appear the corrected code for his function is
<?php
$part["type"] = TYPEAPPLICATION;
$part["encoding"] = ENCBASE64;
$part["subtype"] = "octet-stream";
$part["description"] = $file_name;
$part['disposition.type'] = 'attachment';
$part['disposition'] = array ('filename' => $file_name);
$part['type.parameters'] = array('name' => $file_name);
$part["contents.data"] = base64_encode(fread($file_handle,$file_size));
?>
While this correctly sets the header
Content-Type: application/octet-stream; name="file_name"
Content-Transfer-Encoding: BASE64
Content-Description: file_name
Content-Disposition: attachment; filename="file_name"
But this is still not a good idea to blanket set every attachment as a application/octet-stream so
please consider using the unix command file, or Fileinfo functions (or even trusting file upload
mimetype) and pay attention to the code from "derf dot m at reseaunix dot net"
----
Server IP: 203.202.10.60
Probable Submitter: 210.79.26.194
----
Manual Page -- http://www.php.net/manual/en/function.imap-mail-compose.php
Edit -- https://master.php.net/note/edit/76955
Del: integrated -- https://master.php.net/note/delete/76955/integrated
Del: useless -- https://master.php.net/note/delete/76955/useless
Del: bad code -- https://master.php.net/note/delete/76955/bad+code
Del: spam -- https://master.php.net/note/delete/76955/spam
Del: non-english -- https://master.php.net/note/delete/76955/non-english
Del: in docs -- https://master.php.net/note/delete/76955/in+docs
Del: other reasons-- https://master.php.net/note/delete/76955
Reject -- https://master.php.net/note/reject/76955
Search -- https://master.php.net/manage/user-notes.php