Changeset 91790e4 in github
- Timestamp:
- Feb 9, 2010 8:10:12 AM (3 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- 3e8898e
- Parents:
- 5c54cc0
- Files:
-
- 1 deleted
- 8 edited
-
CHANGELOG (modified) (1 diff)
-
INSTALL (modified) (1 diff)
-
program/include/rcube_imap.php (modified) (1 diff)
-
program/include/rcube_mail_mime.php (deleted)
-
program/include/rcube_smtp.php (modified) (2 diffs)
-
program/lib/imap.inc (modified) (4 diffs)
-
program/steps/mail/attachments.inc (modified) (2 diffs)
-
program/steps/mail/func.inc (modified) (6 diffs)
-
program/steps/mail/sendmail.inc (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
CHANGELOG
r9b94eb6 r91790e4 2 2 =========================== 3 3 4 - Fix attachment excessive memory use, support messages of any size (#1484660) 4 5 - Fix setting task name according to auth state 5 6 - Password: fix vpopmaild driver (#1486478) -
INSTALL
r7d34064 r91790e4 16 16 - libiconv (recommended) 17 17 - mbstring, fileinfo, mcrypt (optional) 18 * PEAR packages distributed with Roundcube or external: 19 - MDB2 2.5.0 or newer 20 - Mail_Mime 1.6.0 or newer 21 - Net_SMTP 1.4.1 or newer 18 22 * php.ini options (see .htaccess file): 19 23 - error_reporting E_ALL & ~E_NOTICE (or lower) -
program/include/rcube_imap.php
rf6b145d r91790e4 1700 1700 * Append a mail message (source) to a specific mailbox 1701 1701 * 1702 * @param string Target mailbox 1703 * @param string Message source 1702 * @param string Target mailbox 1703 * @param string The message source string or filename 1704 * @param string Headers string if $message contains only the body 1705 * @param boolean True if $message is a filename 1706 * 1704 1707 * @return boolean True on success, False on error 1705 1708 */ 1706 function save_message($mbox_name, &$message )1709 function save_message($mbox_name, &$message, $headers='', $is_file=false) 1707 1710 { 1708 1711 $mailbox = $this->mod_mailbox($mbox_name); 1709 1712 1710 1713 // make sure mailbox exists 1711 if (($mailbox == 'INBOX') || in_array($mailbox, $this->_list_mailboxes())) 1712 $saved = iil_C_Append($this->conn, $mailbox, $message); 1714 if (($mailbox == 'INBOX') || in_array($mailbox, $this->_list_mailboxes())) { 1715 if ($is_file) { 1716 $separator = rcmail::get_instance()->config->header_delimiter(); 1717 $saved = iil_C_AppendFromFile($this->conn, $mailbox, $message, 1718 $headers, $separator.$separator); 1719 } 1720 else 1721 $saved = iil_C_Append($this->conn, $mailbox, $message); 1722 } 1713 1723 1714 1724 if ($saved) -
program/include/rcube_smtp.php
r61e96cd r91790e4 142 142 * formatted string 143 143 * 144 * @param string The full text of the message body, including any Mime parts, etc. 144 * @param mixed The full text of the message body, including any Mime parts 145 * or file handle 145 146 * 146 147 * @return bool Returns true on success, or false on error … … 207 208 } 208 209 209 // Concatenate headers and body so it can be passed by reference to SMTP_CONN->data 210 // so preg_replace in SMTP_CONN->quotedata will store a reference instead of a copy. 211 // We are still forced to make another copy here for a couple ticks so we don't really 212 // get to save a copy in the method call. 213 $data = $text_headers . "\r\n" . $body; 214 215 // unset old vars to save data and so we can pass into SMTP_CONN->data by reference. 216 unset($text_headers, $body); 217 210 if (is_resource($body)) 211 { 212 // file handle 213 $data = $body; 214 $text_headers = preg_replace('/[\r\n]+$/', '', $text_headers); 215 } else { 216 // Concatenate headers and body so it can be passed by reference to SMTP_CONN->data 217 // so preg_replace in SMTP_CONN->quotedata will store a reference instead of a copy. 218 // We are still forced to make another copy here for a couple ticks so we don't really 219 // get to save a copy in the method call. 220 $data = $text_headers . "\r\n" . $body; 221 222 // unset old vars to save data and so we can pass into SMTP_CONN->data by reference. 223 unset($text_headers, $body); 224 } 225 218 226 // Send the message's headers and the body as SMTP data. 219 if (PEAR::isError($result = $this->conn->data($data )))227 if (PEAR::isError($result = $this->conn->data($data, $text_headers))) 220 228 { 221 229 $this->error = array('label' => 'smtperror', 'vars' => array('msg' => $result->getMessage())); -
program/lib/imap.inc
ra79e5f1 r91790e4 2419 2419 } 2420 2420 2421 function iil_C_AppendFromFile(&$conn, $folder, $path ) {2421 function iil_C_AppendFromFile(&$conn, $folder, $path, $headers=null, $separator="\n\n") { 2422 2422 if (!$folder) { 2423 2423 return false; … … 2439 2439 return false; 2440 2440 } 2441 2441 2442 if ($headers) { 2443 $headers = preg_replace('/[\r\n]+$/', '', $headers); 2444 $len += strlen($headers) + strlen($separator); 2445 } 2446 2442 2447 //send APPEND command 2443 2448 $request = 'a APPEND "' . iil_Escape($folder) . '" (\\Seen) {' . $len . '}'; … … 2451 2456 } 2452 2457 2453 //send file 2458 // send headers with body separator 2459 if ($headers) { 2460 iil_PutLine($fp, $headers . $separator, false); 2461 } 2462 2463 // send file 2454 2464 while (!feof($in_fp)) { 2455 $buffer = fgets($in_fp, 4096);2465 $buffer = fgets($in_fp, 4096); 2456 2466 iil_PutLine($fp, $buffer, false); 2457 2467 } … … 2460 2470 iil_PutLine($fp, ''); // \r\n 2461 2471 2462 // read response2472 // read response 2463 2473 do { 2464 2474 $line = iil_ReadLine($fp); -
program/steps/mail/attachments.inc
r580ff9c r91790e4 54 54 55 55 if ($attachment['status']) { 56 $size = $attachment['data'] ? strlen($attachment['data']) : @filesize($attachment['path']); 56 if (empty($attachment['size'])) 57 $attachment['size'] = $attachment['data'] ? strlen($attachment['data']) : @filesize($attachment['path']); 58 57 59 header('Content-Type: ' . $attachment['mimetype']); 58 header('Content-Length: ' . $ size);60 header('Content-Length: ' . $attachment['size']); 59 61 60 62 if ($attachment['data']) … … 81 83 $attachment = array( 82 84 'path' => $filepath, 85 'size' => $_FILES['_attachments']['size'][$i], 83 86 'name' => $_FILES['_attachments']['name'][$i], 84 87 'mimetype' => rc_mime_content_type($filepath, $_FILES['_attachments']['name'][$i], $_FILES['_attachments']['type'][$i]) -
program/steps/mail/func.inc
r9b94eb6 r91790e4 1333 1333 1334 1334 /** 1335 * Send the given message compose object using the configured method 1336 */ 1337 function rcmail_deliver_message(&$message, $from, $mailto, &$smtp_error) 1335 * Send the given message using the configured method 1336 * 1337 * @param object $message Reference to Mail_MIME object 1338 * @param string $from Sender address string 1339 * @param array $mailto Array of recipient address strings 1340 * @param array $smtp_error SMTP error array (reference) 1341 * @param string $body_file Location of file with saved message body (reference) 1342 * 1343 * @return boolean Send status. 1344 */ 1345 function rcmail_deliver_message(&$message, $from, $mailto, &$smtp_error, &$body_file) 1338 1346 { 1339 1347 global $CONFIG, $RCMAIL; 1340 1348 1341 $msg_body = $message->get();1342 1349 $headers = $message->headers(); 1343 1350 … … 1358 1365 unset($message->_headers['Bcc']); 1359 1366 1367 $smtp_headers = $message->txtHeaders($send_headers, true); 1368 1369 if ($message->getParam('delay_file_io')) { 1370 // use common temp dir 1371 $temp_dir = $RCMAIL->config->get('temp_dir'); 1372 $body_file = tempnam($temp_dir, 'rcmMsg'); 1373 if (PEAR::isError($mime_result = $message->saveMessageBody($body_file))) { 1374 raise_error(array('code' => 600, 'type' => 'php', 1375 'file' => __FILE__, 'line' => __LINE__, 1376 'message' => "Could not create message: ".$mime_result->getMessage()), 1377 TRUE, FALSE); 1378 return false; 1379 } 1380 $msg_body = fopen($body_file, 'r'); 1381 } else { 1382 $msg_body = $message->get(); 1383 } 1384 1360 1385 // send message 1361 1386 if (!is_object($RCMAIL->smtp)) 1362 1387 $RCMAIL->smtp_init(true); 1363 1388 1364 $sent = $RCMAIL->smtp->send_mail($from, $a_recipients, ($foo = $message->txtHeaders($send_headers, true)), $msg_body);1389 $sent = $RCMAIL->smtp->send_mail($from, $a_recipients, $smtp_headers, $msg_body); 1365 1390 $smtp_response = $RCMAIL->smtp->get_response(); 1366 1391 $smtp_error = $RCMAIL->smtp->get_error(); 1392 1393 if (is_resource($msg_body)) { 1394 fclose($msg_body); 1395 } 1367 1396 1368 1397 // log error … … 1388 1417 } 1389 1418 } 1390 1391 if (ini_get('safe_mode')) 1419 1420 $msg_body = $message->get(); 1421 1422 if (PEAR::isError($msg_body)) 1423 raise_error(array('code' => 600, 'type' => 'php', 1424 'file' => __FILE__, 'line' => __LINE__, 1425 'message' => "Could not create message: ".$msg_body->getMessage()), 1426 TRUE, FALSE); 1427 else if (ini_get('safe_mode')) 1392 1428 $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str); 1393 1429 else … … 1409 1445 } 1410 1446 } 1411 1447 1412 1448 $message->_headers = array(); 1413 1449 $message->headers($headers); … … 1431 1467 $mailto = $recipient['mailto']; 1432 1468 1433 $compose = new rcube_mail_mime($RCMAIL->config->header_delimiter()); 1434 $compose->setParam(array( 1435 'text_encoding' => 'quoted-printable', 1436 'html_encoding' => 'quoted-printable', 1437 'head_encoding' => 'quoted-printable', 1438 'head_charset' => RCMAIL_CHARSET, 1439 'html_charset' => RCMAIL_CHARSET, 1440 'text_charset' => RCMAIL_CHARSET, 1441 )); 1469 $compose = new Mail_mime($RCMAIL->config->header_delimiter()); 1470 1471 $compose->setParam('text_encoding', 'quoted-printable'); 1472 $compose->setParam('html_encoding', 'quoted-printable'); 1473 $compose->setParam('head_encoding', 'quoted-printable'); 1474 $compose->setParam('head_charset', RCMAIL_CHARSET); 1475 $compose->setParam('html_charset', RCMAIL_CHARSET); 1476 $compose->setParam('text_charset', RCMAIL_CHARSET); 1442 1477 1443 1478 // compose headers array … … 1475 1510 $compose->addAttachment($report, 'message/disposition-notification', 'MDNPart2.txt', false, '7bit', 'inline'); 1476 1511 1477 $sent = rcmail_deliver_message($compose, $identity['email'], $mailto, $smtp_error );1512 $sent = rcmail_deliver_message($compose, $identity['email'], $mailto, $smtp_error, $body_file); 1478 1513 1479 1514 if ($sent) -
program/steps/mail/sendmail.inc
rb620493a r91790e4 21 21 */ 22 22 23 24 23 // remove all scripts and act as called in frame 25 24 $OUTPUT->reset(); … … 112 111 global $CONFIG; 113 112 114 $body = $mime_message->getH tmlBody();113 $body = $mime_message->getHTMLBody(); 115 114 116 115 // remove any null-byte characters before parsing … … 135 134 if (! in_array($image_name, $included_images)) { 136 135 // add the image to the MIME message 137 if (! $mime_message->addHTMLImage($img_file, 'image/gif', '', true, $image_name))136 if (! $mime_message->addHTMLImage($img_file, 'image/gif', '', true, $image_name)) 138 137 $OUTPUT->show_message("emoticonerror", 'error'); 139 138 array_push($included_images, $image_name); … … 361 360 $LINE_LENGTH = $RCMAIL->config->get('line_length', 75); 362 361 363 // create extended PEAR::Mail_mime instance 364 $MAIL_MIME = new rcube_mail_mime($RCMAIL->config->header_delimiter()); 362 // Since we can handle big messages with disk usage, we need more time to work 363 @set_time_limit(0); 364 365 // create PEAR::Mail_mime instance 366 $MAIL_MIME = new Mail_mime($RCMAIL->config->header_delimiter()); 367 368 // Check if we have enough memory to handle the message in it 369 // It's faster than using files, so we'll do this if we only can 370 if (is_array($_SESSION['compose']['attachments']) && $CONFIG['smtp_server'] 371 && ($mem_limit = parse_bytes(ini_get('memory_limit')))) 372 { 373 $memory = function_exists('memory_get_usage') ? memory_get_usage() : 16*1024*1024; // safe value: 16MB 374 375 foreach ($_SESSION['compose']['attachments'] as $id => $attachment) 376 $memory += $attachment['size']; 377 378 // Yeah, Net_SMTP needs up to 12x more memory, 1.33 is for base64 379 if ($memory * 1.33 * 12 > $mem_limit) 380 $MAIL_MIME->setParam('delay_file_io', true); 381 } 365 382 366 383 // For HTML-formatted messages, construct the MIME message with both … … 404 421 405 422 // add stored attachments, if any 406 if (is_array($_SESSION['compose']['attachments'])) { 423 if (is_array($_SESSION['compose']['attachments'])) 424 { 407 425 foreach ($_SESSION['compose']['attachments'] as $id => $attachment) { 408 426 // This hook retrieves the attachment contents from the file storage backend … … 439 457 } 440 458 441 // add submitted attachments442 if (is_array($_FILES['_attachments']['tmp_name'])) {443 foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath) {444 $ctype = $files['type'][$i];445 $ctype = str_replace('image/pjpeg', 'image/jpeg', $ctype); // #1484914446 447 $MAIL_MIME->addAttachment($filepath, $ctype, $files['name'][$i], true,448 $ctype == 'message/rfc822' ? $transfer_encoding : 'base64',449 'attachment', $message_charset, '', '',450 $CONFIG['mime_param_folding'] ? 'quoted-printable' : NULL,451 $CONFIG['mime_param_folding'] == 2 ? 'quoted-printable' : NULL452 );453 }454 }455 456 459 // encoding settings for mail composing 457 $MAIL_MIME->setParam(array( 458 'text_encoding' => $transfer_encoding, 459 'html_encoding' => 'quoted-printable', 460 'head_encoding' => 'quoted-printable', 461 'head_charset' => $message_charset, 462 'html_charset' => $message_charset, 463 'text_charset' => $message_charset, 464 )); 460 $MAIL_MIME->setParam('text_encoding', $transfer_encoding); 461 $MAIL_MIME->setParam('html_encoding', 'quoted-printable'); 462 $MAIL_MIME->setParam('head_encoding', 'quoted-printable'); 463 $MAIL_MIME->setParam('head_charset', $message_charset); 464 $MAIL_MIME->setParam('html_charset', $message_charset); 465 $MAIL_MIME->setParam('text_charset', $message_charset); 465 466 466 467 $data = $RCMAIL->plugins->exec_hook('outgoing_message_headers', array('headers' => $headers)); … … 488 489 } 489 490 490 $sent = rcmail_deliver_message($MAIL_MIME, $from, $mailto, $smtp_error );491 491 $sent = rcmail_deliver_message($MAIL_MIME, $from, $mailto, $smtp_error, $mailbody_file); 492 492 493 // return to compose page if sending failed 493 494 if (!$sent) 494 495 { 496 // remove temp file 497 if ($mailbody_file) { 498 unlink($mailbody_file); 499 } 500 495 501 if ($smtp_error) 496 502 $OUTPUT->show_message($smtp_error['label'], 'error', $smtp_error['vars']); … … 513 519 514 520 515 516 521 // Determine which folder to save message 517 522 if ($savedraft) … … 523 528 { 524 529 // check if mailbox exists 525 if (!in_array _nocase($store_target, $IMAP->list_mailboxes()))530 if (!in_array($store_target, $IMAP->list_mailboxes())) 526 531 { 527 532 // folder may be existing but not subscribed (#1485241) 528 if (!in_array _nocase($store_target, $IMAP->list_unsubscribed()))533 if (!in_array($store_target, $IMAP->list_unsubscribed())) 529 534 $store_folder = $IMAP->create_mailbox($store_target, TRUE); 530 535 else if ($IMAP->subscribe($store_target)) … … 533 538 else 534 539 $store_folder = TRUE; 535 540 536 541 // append message to sent box 537 if ($store_folder) 538 $saved = $IMAP->save_message($store_target, $MAIL_MIME->getMessage()); 539 540 // raise error if saving failed 541 if (!$saved) 542 { 543 raise_error(array('code' => 800, 'type' => 'imap', 542 if ($store_folder) { 543 544 // message body in file 545 if ($mailbody_file || $MAIL_MIME->getParam('delay_file_io')) { 546 $headers = $MAIL_MIME->txtHeaders(); 547 548 // file already created 549 if ($mailbody_file) 550 $msg = $mailbody_file; 551 else { 552 $temp_dir = $RCMAIL->config->get('temp_dir'); 553 $mailbody_file = tempnam($temp_dir, 'rcmMsg'); 554 if (!PEAR::isError($msg = $MAIL_MIME->saveMessageBody($mailbody_file))) 555 $msg = $mailbody_file; 556 } 557 } 558 else { 559 $msg = $MAIL_MIME->getMessage(); 560 $headers = ''; 561 } 562 563 if (PEAR::isError($msg)) 564 raise_error(array('code' => 600, 'type' => 'php', 565 'file' => __FILE__, 'line' => __LINE__, 566 'message' => "Could not create message: ".$msg->getMessage()), 567 TRUE, FALSE); 568 else { 569 $saved = $IMAP->save_message($store_target, $msg, $headers, $mailbody_file ? true : false); 570 } 571 572 if ($mailbody_file) { 573 unlink($mailbody_file); 574 $mailbody_file = null; 575 } 576 577 // raise error if saving failed 578 if (!$saved) { 579 raise_error(array('code' => 800, 'type' => 'imap', 544 580 'file' => __FILE__, 'line' => __LINE__, 545 581 'message' => "Could not save message in $store_target"), TRUE, FALSE); 546 582 547 if ($savedraft) { 548 $OUTPUT->show_message('errorsaving', 'error'); 549 $OUTPUT->send('iframe'); 583 if ($savedraft) { 584 $OUTPUT->show_message('errorsaving', 'error'); 585 $OUTPUT->send('iframe'); 586 } 550 587 } 551 588 } … … 565 602 } 566 603 } 604 // remove temp file 605 else if ($mailbody_file) { 606 unlink($mailbody_file); 607 } 608 567 609 568 610 if ($savedraft)
Note: See TracChangeset
for help on using the changeset viewer.
