summaryrefslogtreecommitdiff
path: root/program/lib/imap.inc
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2010-02-09 13:10:12 +0000
committeralecpl <alec@alec.pl>2010-02-09 13:10:12 +0000
commit91790e41f3fa307658077043bc2fa5f71e270cf4 (patch)
tree9864a79c0524eb064c2d07b78180394d5d9c9adf /program/lib/imap.inc
parent5c54cc0ee6de44960bbc4cfab3d456a4805a0692 (diff)
- Fix attachment excessive memory use, support messages of any size (#1484660)
Diffstat (limited to 'program/lib/imap.inc')
-rw-r--r--program/lib/imap.inc20
1 files changed, 15 insertions, 5 deletions
diff --git a/program/lib/imap.inc b/program/lib/imap.inc
index 7607a1c71..ed30937fa 100644
--- a/program/lib/imap.inc
+++ b/program/lib/imap.inc
@@ -2418,7 +2418,7 @@ function iil_C_Append(&$conn, $folder, &$message) {
return false;
}
-function iil_C_AppendFromFile(&$conn, $folder, $path) {
+function iil_C_AppendFromFile(&$conn, $folder, $path, $headers=null, $separator="\n\n") {
if (!$folder) {
return false;
}
@@ -2438,7 +2438,12 @@ function iil_C_AppendFromFile(&$conn, $folder, $path) {
if (!$len) {
return false;
}
-
+
+ if ($headers) {
+ $headers = preg_replace('/[\r\n]+$/', '', $headers);
+ $len += strlen($headers) + strlen($separator);
+ }
+
//send APPEND command
$request = 'a APPEND "' . iil_Escape($folder) . '" (\\Seen) {' . $len . '}';
if (iil_PutLine($fp, $request)) {
@@ -2450,16 +2455,21 @@ function iil_C_AppendFromFile(&$conn, $folder, $path) {
return false;
}
- //send file
+ // send headers with body separator
+ if ($headers) {
+ iil_PutLine($fp, $headers . $separator, false);
+ }
+
+ // send file
while (!feof($in_fp)) {
- $buffer = fgets($in_fp, 4096);
+ $buffer = fgets($in_fp, 4096);
iil_PutLine($fp, $buffer, false);
}
fclose($in_fp);
iil_PutLine($fp, ''); // \r\n
- //read response
+ // read response
do {
$line = iil_ReadLine($fp);
} while (!iil_StartsWith($line, 'a ', true));